Jump to content

File Count Problem


brad_langdon

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/175308-file-count-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.