using php to get a random record from a mysql database and display the results?

av3ng3dwarri0r

New member
i have a mysql database full of movie titles and i need to get a random one using php and display it in the browser. the code i tried is:

$range_result = mysql_query( " SELECT MAX(id) AS max_id , MIN(id) AS min_id FROM Movies ");
$range_row = mysql_fetch_object( $range_result );
$random = mt_rand( $range_row->min_id , $range_row->max_id );
$result = mysql_query( " SELECT * FROM WHERE id >= $random LIMIT 0,1 ");

echo "Your movie selection for tonight is: ".$result;

how the fuck do i fix this shit?
 
Back
Top