I do the same - this is a two stage setup I use - the first is a page showing all the different galleries I have (folders inside the galleries folder)
// open directory and make an array of all the folders in the gallery folder
$myDirectory = opendir("images/gallery/");
// get each entry
while (false !== ($file = readdir($myDirectory))) {
if ($file != "." && $file != "..") {
$dirArray[] = $file;
}
}
// close directory
closedir($myDirectory);
sort ($dirArray);
// count elements in array
$indexCount = count($dirArray);
//loop through the array of folders and print them all
for($index=0; $index < $indexCount; $index++) {
$linktext = ($dirArray[$index]);
$pickImage = opendir("images/gallery/".$linktext);
// actually look in the folder and pick an image to display - you could cut this out if you don't want a picture shown
while (false !== ($imageName = readdir($pickImage))) {
if ($imageName != "." && $imageName != "..") {
$picArray[] = $imageName;
}
}
// close directory
closedir($pickImage);
sort ($picArray);
$useThisImage = ($picArray[1]);
echo "
\n";
echo "

\n";
$linktext = str_replace("-", " ", $linktext);
echo $linktext;
echo "
\n";
$picArray ="";
}
?>
this is the second page it gets the gallery name from the link in the previous page - if all you want is one gallery and to show all the images in that one alone, only use this code and set the variable $thisGallery in the first line to the relative location of your file.
$thisGallery = "images/gallery/".$_GET['gallery'];
$myImageDirectory = opendir($thisGallery);
while($entryImageName = readdir($myImageDirectory)) {
if ($entryImageName != "." && $entryImageName != ".." ) {
$dirImageArray[] = $entryImageName;
}
}
closedir($myImageDirectory);
sort ($dirImageArray);
$indexImageCount = count($dirImageArray);
for($indexImage=0; $indexImage < $indexImageCount; $indexImage++) {
echo "
."\"/)
\n";
}
?>
If you need any further help look for us at tomate design in Mexico