gibrst Posted March 12, 2008 Share Posted March 12, 2008 Ok, im having a bit of trouble, im trying to create just a very simple ad rotator, but the ads are in categories! So, in the table there is ID, ad image, category And i basically want to when page loads, show a random ad where the category is "a certain category"? Anyone know how i could do this? Cheers Andy Quote Link to comment https://forums.phpfreaks.com/topic/95720-im-sure-simple-for-somone-selecting-from-database-randomly/ Share on other sites More sharing options...
MadTechie Posted March 12, 2008 Share Posted March 12, 2008 what do you have so far ? <?php $cat = "cars"; $SQL= "SELECT * FROM `table` WHERE Cat = '$cat' order by RAND() limit 1;"; ?> theirs better random routines for mysql this one was just a quicky Quote Link to comment https://forums.phpfreaks.com/topic/95720-im-sure-simple-for-somone-selecting-from-database-randomly/#findComment-490085 Share on other sites More sharing options...
gibrst Posted March 12, 2008 Author Share Posted March 12, 2008 That will do nicely, lol.. i wernt far out, just for some reason lost me mind and got me self confused! Cheers! Andy Quote Link to comment https://forums.phpfreaks.com/topic/95720-im-sure-simple-for-somone-selecting-from-database-randomly/#findComment-490087 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.