First of all let me say that I did find an error in my own script:
if ($file != "." && $file != ".." && file !=!is_dir($file)) {
You'll notice right before the !is_dir call, that I accidentally inserted a != so I got rid of that which also changed the results a bit.
Now instead of no pictures showing up. I get one picture. And I believe the readdir function should bring the results in alphabetical order as that's how they are held in the filesystem but the one image that gets returned is "end.jpg" which should come after all the numeric photos as well as the A's, B's, C's, and D's. So why is that happening?
Okay so the debug script I produced is:
if (isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
$x = $start;
$current_page = ($start/$display) + 1;
$currmaxdisplay = ($start+$display);
function createGallery($path, $thumbpath){
echo "CALL to createGallery, parameters $path, $thumbpath<br />";
echo "Start Variable is: $start<br />";
echo "Current maximum display is: $currmaxdisplay.<br />";
if (($dir = opendir($path))){
echo "1st IF statement is okay.<br />";
// loops through while the readdir function returns true.
while ((false !== ($file = readdir($dir))) && ($x <= $currmaxdisplay)) {
// picks only valid filenames
if ($file != "." && $file != ".." && !is_dir($file)) {
echo "Inner IF statement is okay as well.<br />";
echo "X Variable #1 = $x<br />";
$imgtitlea = substr($file, 0, strrpos($file, '.'));
$imgtitle = str_replace("_"," ",$imgtitlea);
// echos to the client a nice unordered list of images
echo
"<li>".
"<a href=\"".$path."/".$file."\" rel=\"lightbox[page]\" title=\"".$imgtitle."\">
<img src=\"".$thumbpath."/".$file."\" alt=\"".$imgtitle."\" width=\"40\" border=\"0\" />
<img src=\"".$thumbpath."/".$file."\" alt=\"".$imgtitle."\" class=\"preview\" />
</a>".
"</li>";
$x++;
echo "X Variable #2 = $x<br />";
echo "+";
}
}
}
echo "</ul>";
}
The results of the debug can be found at http://www.experimentalillness.com/photos/experiment/index.php?type=polaroids. Now the things that are catching my eye is that the $start variable is being echoed as empty. When as you can see, I have it being set to 0 if the URL does not contain its value. Why in the world is it being left empty. And why is only one image being returned now?! And as you can see, because $start is being left empty, $currmaxdisplay is being returned empty as well. That must be what is throwing my function off but why is it happening, is anything glaringly obvious to anyone else?
Any help is appreciated and matto I appreciate your reply, I usually get no answers when I look to forums so I appreciate your effort to help me.
EDIT: For those who don't want to go to an external link to see the debug results, I thought I'd include them:
CALL to createGallery, parameters polaroids/fullsize, polaroids/thumbs
Start Variable is:
Current maximum display is:
1st IF statement is okay.
Inner IF statement is okay as well.
X Variable #1 =
X Variable #2 = 1
+