I had done this using my MySQL db, but about a year ago, I revamped my site to a more conveniently-coding layout for my photography thumbnails. Someone else had written the code, and it uses the opendir functionality to auto-create thumbnail images based on the image files in a particular folder.
The problem is if I have a gallery with 100+ images in it, it loads all of them on the page and the user can't select anything to view until they've all loaded.
I want to create pagination to load, say, 15 at a time and then allow the user to go to the other pages (if there are any). This code was written way over my head, as I'm quite the PHP novice.
Here is the code I think is relevant that needs to be updated:
$dir = $dir.$gallery."/";
//Put files into an array
// create a handler to the directory
$dirhandler = opendir($dir);
// read all the files from directory
$nofiles=0;
while ($file = readdir($dirhandler)) {
// if $file isn't this directory or its parent
//add to the $files array
if ($file != '.' && $file != '..')
{
$nofiles++;
$files[$nofiles]=$file;
}
}
//close the handler
closedir($dirhandler);
// sort folder names alphabetically, ignore case
natcasesort($files);
?>
<div style="clear:both"></div>
<?
//Show images
foreach ($files as $file){
if ($file!="."&&$file!="..")
{
$extention = explode('.', $file);
if ($extention[1] != "")
{
echo "<div class='imgwrapper'>";
echo"<a class='fancybox' rel='group' href='$dir$file' return='false' title='$filename'>";
echo "<img src='timthumb.php?src=$dir$file&h=$height&w=$width' alt='$extention[0]' width='$width' height='$height'>";
echo"</a><br>";
echo "</div>";
}
}
}
?>
That might not even be everything. Honestly, I'm willing to pay someone to do this for me. I don't know how hard or easy it is. I can send the entire page or copy the entire code if necessary.
I spent 7 hours yesterday trying to convert my site into a WordPress layout where there is a web gallery plugin that already does this, but the mobile layout is a mess and it's a little more complicated than what this code already does easily.
I think my current site looks and works great, but this pagination is the only thing missing.