phpretard Posted March 9, 2008 Share Posted March 9, 2008 Is there a code to SELECT * FROM a table and ORDER by a row, but randomly select the order? -Thank you Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 9, 2008 Share Posted March 9, 2008 have a look here at mysql reference for RAND() http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_rand It looks like it may do the job. SELECT * FROM quotation ORDER BY RAND() may work but i have not tested. Regards Liam Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 9, 2008 Author Share Posted March 9, 2008 Dude...have no idea what I'm reading there...it looks impressive though. Thank you. I want to display random ads down one side of a site I'm working on. There are plenty of unique rows I can select. Once selected, I need them to display randomly (not asc or desc). I can do it javascript, but prefer php. -Anthony Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 9, 2008 Share Posted March 9, 2008 The query "SELECT * from tablename ORDER by RAND() LIMIT 5" would choose 5 at random. Does that help? Quote Link to comment 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.