php random select information from a database

something very loosely along the lines of

SELECT MAX(id) FROM table

$fields = mysql_result($sql, 0);

$randid = rand(0,$fields);

SELECT * FROM table WHERE id = $randid
 
[edit] ok got it working.

reason it wasn't working was because i was including another file before that so some reason didn't allow this. anyone know why as i need to include the other file for the login on another page which will also have the code just added.

Thanks
 
Last edited:
Back
Top Bottom