PHP to post links to sub directories & php to display images
I'm very basic when it comes to PHP.
With my website, I have a directory called "uploads"
Within "uploads" I have 3 folders "Example1" "Example2" and "Example3"
Within each of the folders, they contain images.
I need to know how to use php to create a navigation for every sub
directory. So that if I add a new folder "Example4" it will give a
navigation like:
Select what section you're looking for:
Example1 | Example2 | Example3
and if I later add new folders add them to the navigation. EX:
Example1 | Example2 | Example3 | Example4 | Example5
Then once they click the link to go into the folder, have a code that
displays all the images in that folder.
So far I have:
<?php
$files = glob("uploads/*.*");
for ($i=0; $i<count($files); $i++)
{
$num = $files[$i];
echo '<a href="/'.$num.'"><img src="/'.$num.'"></a>'."<p>";
}
?>
but it will only display the images in the upload directory, not the
images in Example1 and so on.
How on earth would I go about doing this? I'm doing it for a school
project and have two weeks to complete it, but I am so lost. I only have
knowledge with CSS, HTML, and the only PHP I know is php includes, so any
help would be appreciated.
No comments:
Post a Comment