Thank you laserlight. I did see the Roger Ramjet's idea:
// get the highest 2 ids
$res1 = mysql_query("SELECT id FROM table ORDER BY id DESC LIMIT 2");
// generate random no between 0 and second highest id
$top = mysql_result($res1,1);
$rand = rand(0,$top);
// now query for id greater then random no
$sql = "SELECT * FROM table WHERE id>$rand ORDER BY id DESC LIMIT 1"
I had the same idea but the problem is that I need to select rows with "where" statement:
.... where image='1'
If $rand is a number which selects the last rows from the table, and all rows or some rows have image='0', the script will not display any last images. There may be several hundreds of last rows in the table with image='0' 🙁