brad_langdon Posted September 24, 2009 Share Posted September 24, 2009 Hi, The following script lists the folders in my "Photos" folder as links to another page. That part works fine. What I want now is to get a count of the images inside each folder that the script has listed. So basically the script finds the folders inside "Photos" folder and now I want it to display the amount of images in each folder next to the folder name / the link. <?php $dir = opendir('Photos/'); // Open Folder "Photos" and find files inside (in this case folders not files) echo "<ul id='frontpage'>"; while ($read = readdir($dir)) { if ($read!='.' && $read!='..') { // List all folders in "Photos" as "<li>'s" in the list echo "<li id='infocon'><a href='photos.php?cat=$read' class='frontpage'><img src='Photos/$read/01.jpg' class='frontpage' /> <h1 style=\"background: url('images/".$read.".png') no-repeat top left;\" \>$read</h1>"; echo "<h2> I WANT THE FILECOUNT TO GO HERE </h2></a></li>"; } } echo "</ul>"; closedir($dir); // Close directory ?> Any help will be of course much appreciated. I have tried a few methods I saw online with no luck. I think it may have to do with the fact that I was trying to read a directory while a directory was already open or something... just guessing, I am no expert. Quote Link to comment Share on other sites More sharing options...
corbin Posted September 24, 2009 Share Posted September 24, 2009 Hrmmm, you could open a handle to the folder (opendir), read the directory (readdir) and then increment a counter if is_dir is false. Quote Link to comment Share on other sites More sharing options...
brad_langdon Posted September 24, 2009 Author Share Posted September 24, 2009 Thanks, Sorry but how would that go... I don't really know how to do that. Also would it matter that I already have a directory open to get the folder names? Quote Link to comment Share on other sites More sharing options...
brad_langdon Posted September 24, 2009 Author Share Posted September 24, 2009 Anybody know how to do that? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.