Hello,
I'm trying to display 5 different images on one HTML page (in one column) such that each time the page is refreshed the order the images are displayed in will change, but all images are displayed every page load and each image has a URL associated with it. I've gotten close with this...
<?php
// rotate images randomly but w/o dups on same page - format:
// <img src='rotate.php?i=0'> - rotate image #0 - use 'i=1'
// for second, etc
// (c) 2004 David Pankhurst - use freely, but please leave in my credit
$images=array( // list of files to rotate - add as needed
"images/1.jpg",
"images/2.jpg",
"images/3.jpg",
"images/4.jpg",
"images/5.jpg", );
$total=count($images);
$secondsFixed=10; // seconds to keep list the same
$seedValue=(int)(time()/$secondsFixed);
srand($seedValue);
for ($i=0;$i<$total;++$i) // shuffle list 'randomly'
{
$r=rand(0,$total-1);
$temp =$images[$i];
$images[$i]=$images[$r];
$images[$r]=$temp;
}
$index=(int)($_GET['i']); // image index passed in
$i=$index%$total; // make sure index always in bounds
$file=$images[$i];
header("Location: $file"); // and pass file reference back
?>
<html>
<img src='images/rotate.php?i=0'>
<img src='images/rotate.php?i=1'>
<img src='images/rotate.php?i=2'>
<img src='images/rotate.php?i=3'>
<img src='images/rotate.php?i=4'>
</html>
...but the only thing I can't figure out is how to associate URLs with the images. I tried an href around the img src but obviously that just applied a specific URL to whichever picture was called that time around. Can someone point me in the right direction? ??? Thanks.