I’m developing an image gallery where there are heaps of images in various countries, and from within the countries, different regions.
My filing system for the images on the server are as follows:
httpdocs
-images
–countries
—country name
—-region
I want to start off at the countries folder, and display all of the subfolders contained within.
That’s the easy part.
My code attached:
<?PHP
$heading = “Countries”;
print “<big><b>”;
print $heading;
print “</b></big><br>”;
$dir = “images/countries”;
$handle = opendir($dir);
$num = 0;
while (false !== ($file = readdir($handle))) {
if ($file != “.” && $file != “..”) {
echo “<a href=”$dir/$file” class=”directory”>$file</a><br>”;
$num++;
}
}
closedir($handle);
?>
Each sub-folder of “dir-countries” is listed in <a href> format.
The problem is that the link is not pointing at this moment to a file, but it’s pointing to more folders.
I want to be able to click on a country, and have the list refresh by now reading the subfolders of the country I just clicked.
Any ideas?
Pyro helped out the other day showing me how to use an href to activate a function in a php script, but I can’t seem to see how I could use a similar technique in the above code.
Bit of a long one, but hope someone has done this kind of thing before.
Thanks,
John