Hi! I'm trying to show 5 random images from my database and i seem to be stuck.
Would appreciate some help or tips.
I obviously dont want any duplicate images. Have tried to figure it out by googling butt my head hurts too much xD
Got thumbnails for the picture and am showing them with lightbox.
Here is the code
$result = mysql_query("SELECT * FROM imgupload");
$count = 1;
$num_rows = mysql_num_rows($result);
echo "<br />";
$query = mysql_query("SELECT * FROM imgupload ORDER BY RAND()");
$row = mysql_fetch_row($query);
$kaboom = explode("/",$row);
echo "<a href='$row' rel='lightbox[group]' title='$row');><img src='$kaboom/resized_$kaboom'></a>";
$count = $count + 1;
The other options are quite contrived and sometimes use more than one query. For everyday use on small tables (<1000 records - a number I plucked out of the air!), it should matter much. On bigger tables, a different approach may be req'd.
If it's solved, mark it so, with the link below the edit box.