Hey all, I am working on this script for a PHP Image Gallery and I’m stuck! I got it to select the folders and images within folders and display and link them, but I don’t know how to get it to display only a certain number of images per page and have different pages for the images! Could someone help me out!? Here’s the script:
<?php
if (isset($_GET["page"])) {
$dir = $_GET["page"] . "/";
if (is_dir($dir)) {
if ($handle = opendir('./' . $dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "gallery.php" && $file != "Thumbs.db") {
if (is_dir($file)) {
echo "<a href="gallery.php?page=$dir$file">$file</a>n";
} else {
echo "<img src="$dir$file">";
}
}
}
closedir($handle);
$total_images = count(glob('./' . $dir . '{*.gif,*.jpg,*.png}', GLOB_BRACE));
echo "Total Images: " . $total_images;
}
} else {
$dir2 = substr($dir, 0, -1);
echo "<img src="$dir2">";
}
} else {
$dir = "";
if ($handle = opendir('./' . $dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "gallery.php" && $file != "Thumbs.db") {
if (is_dir($file)) {
echo "<a href="gallery.php?page=$dir$file">$file</a>n";
} else {
echo "<img src="$file">";
}
}
}
closedir($handle);
$total_images = count(glob('./' . $dir . '{*.gif,*.jpg,*.png}', GLOB_BRACE));
echo "Total Images: " . $total_images;
}
}
?>