Orionsbelter Posted August 22, 2009 Share Posted August 22, 2009 Ok, so i'm wanting to randomly select one user from the table users, however this user has to be online. like this, $time=time(); mysql_query("SELECT username, id FROM users WHERE online > $time"); The way i was going to do it is, i was going to put all the user IDs into an array and randomly pick one, but if you know a better way please do tell me. I would like to know how i can put all the user ID into an array, from that string as i only know how to array PHP and not mysql strings. Thank You Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 22, 2009 Share Posted August 22, 2009 <?php $time=time(); mysql_query("SELECT username, id FROM users WHERE online > $time ORDER BY RAND() LIMIT 1"); ?> Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted August 22, 2009 Author Share Posted August 22, 2009 Thanks, just for the future, how would i array a mysql string? 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.