I just got pagination to work on my site, but I wanted to use a thumbnailer script that accepts a path, not a resource. This conflicts with how I pagination- using readdir to scan for a resource.
Right now I'm implementing a skip pattern I found online to keep track of images and their corresponding page numbers:
while ( $count <= $skip && ($file = readdir($handle)) !== false ) {
if ( !is_dir($file))
$count++;
}
$count = 0;
So,
Question 1) This method sets $count = 0 after it's run, so I don't see how it can be useful for the rest of the script.
Question 2) This part actually displays the correct images on page according to page number. I set $imagesPerPage = 4, so 4 should display on all pages. But, since I'm doing an !is_dir check, it's truncating those first two items (which are directories . and ..), but it's not refilling those spots with actual images (bec all pages except the last page should have 4 images on them...)
while ( $count++ < $imagesPerPage && ($file = readdir($handle)) !== false ) {
if(!is_dir($file)) {
$image = $imagePath . $file;
?>
<a href="../templates/viewComic.php?image=<?php echo $image ?>"><img src="../scripts/thumbnailer2.php?img=<?php echo $image ?>" /></a>
<?php
}
}
Question 3) How can I get the pages to begin on 1 instead of 0?
Any help in understanding would be appreciated!