Forum Moderators: coopster
This is what I have and it appears to work but I'm not 100% certain of it. Did I do this right?
$sql_test = "SELECT * FROM sponsors WHERE valid = 'yes'";
$result_test = mysql_query($sql_test);
$num = mysql_num_rows($result_test);
srand((float) microtime() * 10000000);
while($row = mysql_fetch_row($result_test)) {
if ($row[3] == NULL)
$link = "";
else
$link = "href";
$myArray[$row[0]] = "<a ".$link."='../postlink.php?link=http://".$row[3]."' target='_blank'><img src='images/".$row[2]."' border='0' alt='".$row[1]."'></a>";
}
$rand_keys = array_rand($myArray, $num);
$sponsor = $myArray[$rand_keys[0]];