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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.