I have googled and read articles but nothing seems to work how I want it to work so I'll try my best to put it into perspective here and hope that someone can help this idea become more than just that.
I am EXTREMELY new to php and I can't seem to wrap my head around all of it just yet, I only have a basic idea of certain usages that I can do with it however with bigger ideas, like this one. I am at a loss. If I need to explain it better, please let me know and I can try my best.
Main page index.php in a list:
Folder name (# of images in directory)
Folder name (# of images in directory)
Or if it has a subfolder it is:
Click main category link and displays these links to sub directory
- Sub Folder Name (# of images in directory) - Sub Folder Name (# of images in directory)
Then when you click on the subfolder or folder link, it takes you to:
index.php?cat=Folder name or index.php?cat=Subfolder name And displays the images (not lists them) in the folder or subfolder.
Any help is appreciated.
I have tried this and it seems to work but only for one level directory and not sub directories, I also cannot seem to get the number of images in the folder to show up either..
index.php
<?php
$path = 'uploads';
$folders = glob($path.'/*');
echo '<ul>';
foreach ($folders as $folder) {
echo '<li><a href="images.php?folder='.$folder.'">'.$folder.'</a></li>';
}
echo '</ul>';
?>
images.php
<?php
if (isset($_GET['folder'])) {
$folder = $_GET['folder'];
}
$singleImages = array();
foreach (glob($folder . '/*.{jpg,jpeg,png,gif}', GLOB_BRACE) as $image) {
$imageElements = array();
$imageElements['source'] = $image;
$singleImages[$image] = $imageElements;
}
foreach ($singleImages as $image) {
echo '<a href="'.$image['source'].'"><img src="'.$image['source'].'"></a>';
}
?>
----------AND UPDATE----------
I would ideally love for it to display a certain number per page and have a pagination if it goes over that number? That might be dreaming a little too big with the directories and sub-directory displays.
I hope this makes sense. I've been working on this for over a week now and this is only as far as I have gotten with it. Thank you for any suggestions/tips/help. I really appreciate even the time anyone takes to read this.