I am attempting to do is random image rotation on the index page, I have followed this sitepoint tutorial on how to code a php image rotation and would like to make sure that the page calls on the php file properly. I have created a separate php file below is the code:
<?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/paulinewoolley/bjarg.jpg",
"images/paulinewoolley/ion.jpg",
"images/paulinewoolley/foss.jpg",
"images/paulinewoolley/altitude1.jpg",
"images/paulinewoolley/altitude5.jpg",
"images/paulinewoolley/altitude6.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
?>
Here is the code that would be placed on the html file
<img src='canstudios.org/rotate.php?i=0'>image #1
<img src='canstudios.org/rotate.php?i=1'>image #2
<img src='canstudios.org/rotate.php?i=2'>image #3