orbitter Posted March 1, 2008 Share Posted March 1, 2008 hi there, if anyone can help, i am trying to produce a code using php to randomly output different peoples names (which are stored in a mysql database table) on a new page within the web browser every time a submit button is pressed. any help would be much appreciated. thank you Quote Link to comment Share on other sites More sharing options...
nano Posted March 1, 2008 Share Posted March 1, 2008 did u search? i am no php guru, but a from a simple search I found a few pages. http://www.learningmovabletype.com/a/001037random_quotes/ seems to be using the ORDER by rand() function when running a database query. hope this helps! Quote Link to comment Share on other sites More sharing options...
beebum Posted March 1, 2008 Share Posted March 1, 2008 Look at MySQL's rand() function. http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_rand Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted March 1, 2008 Share Posted March 1, 2008 hmmmm your code will be something lyk... <? $noobs= mysql_query("SELECT * FROM users ORDER BY RAND()"); $no_of_noobs= mysql_num_rows($noobs); if ($no_of_noobs == "0"){ echo "No noobs could be selected from the db"; }else{ $the= mysql_fetch_object($noobs); echo $the->username; } ?> you might have to change a few stuff accordingly to your database Quote Link to comment Share on other sites More sharing options...
orbitter Posted March 1, 2008 Author Share Posted March 1, 2008 thank you so much guys, appreciate the 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.