coolphpdude Posted July 3, 2008 Share Posted July 3, 2008 Hi there, If i have got 10 'messages of the day' in a table for example that are relevant to a user. how would i select all records from that table that are relevant to the user but only display 1 at random. so if a user was to log in it would show a random 1 of those 10 messages, if he was to log in again later on that day it would select another message at random? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/113133-select-random/ Share on other sites More sharing options...
discomatt Posted July 3, 2008 Share Posted July 3, 2008 I'm assuming a database table? I'm also assuming MySQL? Quote Link to comment https://forums.phpfreaks.com/topic/113133-select-random/#findComment-581195 Share on other sites More sharing options...
lemmin Posted July 3, 2008 Share Posted July 3, 2008 This works: "...ORDER BY RAND() LIMIT 1" Quote Link to comment https://forums.phpfreaks.com/topic/113133-select-random/#findComment-581198 Share on other sites More sharing options...
coolphpdude Posted July 3, 2008 Author Share Posted July 3, 2008 yeah sorry database table on MySQL. I'll give that order by random thing a go! I've just messed everything up trying a very long way to go about it s i'll have to put that back together first!!! Oh the joy! Thanks for your help guys! Quote Link to comment https://forums.phpfreaks.com/topic/113133-select-random/#findComment-581214 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.