This Page Contains information about How To Display Random Information From MySQL Database PHP Function By wallpaperama in category MySQL with 0 Replies. Last Upated: Thu Nov 13, 2014 
Sometimes you want display random information from your database. I had a hardtime figuring out how to do is with php. I found the RAND() functions works greate with MySQL. Here I have create a snippet to help give you a sample code script:
The following example will display one output from your table. You can display multiple fields by doing a loop.
example: Make sure to provide your database information like your username, password, etc..
# Random Snippet Code Sample by http://www.wallpaperama.com
$db_host = 'localhost';
$db_username = 'myusername';
$db_password = 'mypassword';
$db_dbname = 'mydatabase_name';
# END CONFIGURE
$database = mysql_connect($db_host, $db_username, $db_password);
$sql = "SELECT * FROM table_name ORDER BY RAND()";
$result = mysql_query($sql ,$db);
$myrow = mysql_fetch_array($result);
* make sure to edit the script and provide your correct table_name
from your table, ( i used table_name and field_name as an example)