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 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 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 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
Archived
This topic is now archived and is closed to further replies.