How do i randomly select 4 diferent pictures?
I'm using the function below to select 1 random picture... BUT when i use this function 4 times i get 4 pictures with sometimes 2 the same... (logical offcourse) How can i avoid this?
I want 4 diferent random pictures or ID's to include in an img tag.
Thanks,
Gerry
function random_picture() {
global $CFG;
$qid = mysql_query("SELECT * from download_image");
$max = mysql_num_rows($qid)-1;
mt_srand((double)microtime()*1000000);
if ($max > 0) {
$random = mt_rand(0,$max);
} else {
$random = 0;
}
for ($x=0;$x<=$random;$x++) {
$myrow = mysql_fetch_array($qid);
}
$id = $myrow["id"];
echo "<img src='./admin/images/idc/" . $id ."_t.jpg' border=0>";
}