Hi, I have a PHP script that reads images from a folder, loads it into an array, displays each image and links to that specific image. However, Everytime I call the program again after clicking an image, it seems that the next/previous links lose their information in regards to the next/previous file in the array. How can I keep the next/previous links to retain the array information?
here is my script:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head> <body bgcolor="#FFFFFF">
<div align="center"><center>
<?
//register globals
global $a;
global $picList;
global $nindx;
global $pindx;
global $indx;
global $mssg;
$mssg = "haha";
$photo=$REQUEST["photo"];
$next=$REQUEST["next"];
$prev=$_REQUEST["prev"];
//ryans lil photo gallery thing
$a = '0';
$filepath = "thumbs/";
$url_path = "images/";
$dp = opendir($filepath);
// BEGIN THUMBNAILS
while ($currentFile !==false){
$currentFile = readDir($dp);
if ($currentFile == "." || $currentFile =="..") {
continue;
}
$theFiles[] = $currentFile;
}
$imageFiles = preg_grep("/jpg$|gif$/",$theFiles);
$next=$imageFiles[$i+1];
$prev=$imageFiles[$i-1];
if (empty($photo)) {
print "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"50%\">";
for($i=0; $i< count($imageFiles); $i++){
if ($a=="0") {print "<tr>";}
if ($a=="3") {print "</tr><tr>"; $a="0";}
print <<<HERE
<td>
$i<br>
<a href = "forloop.php?photo=$imageFiles[$i]&next=$next&prev=$prev">
<img src="$filepath/$imageFiles[$i]"></a>
</td>
HERE;
$a=$a+1;
}
}
// END THUMBNAILS
else {
// BEGIN MAIN PHOTO DISPLAY
print <<<HERE
<img src="images/$photo">
$next
$prev
HERE;
}
?>
</tr>
</table>
</center></div>
</body>
</html>