I have a while loop that checks how many images in a folder and then displays a slideshow. It shows the first image, adds 1 to a $num variable and refreshes the page (it should show number 2 image until it reaches variable $total (total files in the folder). It shows the first fine, waits the 3 seconds but then jumps straight to the last image, missing out the ones in the middle.
Can be seen here http://photos.comports.net/?folder=pics/Our%20Wedding/ and click on slideshow.
I have also shown the code
Code: Select all
<?php
session_start();
error_reporting(0);
print"<HTML>
<HEAD>
<TITLE>PhotStore Slide Show</TITLE>
<META NAME=\"Generator\" CONTENT=\"EditPlus\">
<META NAME=\"Author\" CONTENT=\"Ashley Byrne\">
<META NAME=\"Keywords\" CONTENT=\"Image Gallery\">
<META NAME=\"Description\" CONTENT=\"\">
<link rel=\"stylesheet\" href=\"style2.css\">";
print"</HEAD><BODY background=\"slideback.gif\"><center><table border=0 cellspacing=0 cellpadding=0 width=\"100%\" height=\"100%\" bgcolor=\"#669966\">";
$pwd = $_SESSION['pwd'];
$num = $_GET["num"];
$show= $_GET["show"];
$folder = $_GET["folder"];
$dir = opendir($folder);
$i=1;
while ($a = readdir($dir)) {
if($a != "." && $a != ".."){
$files[$i] = $a;
++$i;
}
}
$total = count($files);
// resize the image if its too big
$maxwidth="600";
list($width, $height, $type, $attr) = getimagesize($folder.$files[$num]);
if($width>$maxwidth){
$widthpc = round(($maxwidth/$width)*100);
$width = round(($width*$widthpc)/100);
$height = round(($height*$widthpc)/100);
$attr="width=".$width." height=".$height;
}
Else{
$attr="width=".$width." height=".$height;
}
print "<tr><td><center><b><font color=\"white\">".substr($folder,5,-1)." - ".substr($files[$num],0,-4)."</b> (". $num. " of ". $total.")</b></td></tr>";
print "<tr><td><center><img src=\"".$folder.$files[$num]."\" ".$attr." border=1><br>".$attr."</td></tr>";
print "<tr><td><br><center><a href=\"javascript:parent.window.close()\"><font color=\"white\">--| End slideshow |--</a></td></tr>";
while ($num < $total){
print "next file is going to be = ".$num. " of ". $total;
print "<META HTTP-EQUIV=\"refresh\" content=\"3; URL=?folder=".$folder."&num=".$num."\"></td></tr></table>";
$num = ($num+1);
}
?>
Thanks
Ashley