Look at the php.net site for the functions relating to directories such as isdir(), readdir().
Simply read the contents of the directory while looping and count the number of files, then echo or print the results. Exclude the sub-directories while looping.
That is a rough outline of the the pseudo-code to perform the task. I think I have a script which might need some changes to it in order to do exactly what you want. Do you code in php? If so, PM me and I'll see if I can find it to send to you.
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict Page to List the files in this directory</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>
<p>... Your HTML content here ...</p>
<?php
//dir_list.php
$default_dir = "./"; // lists files only for the directory which this script is run from
echo '<div id="link_div"><ul>' . "\r\n\t";
if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
while($file = readdir($dp)) {
if(is_dir($file)) {
continue;
}
else if($file != '.' && $file != '..') {
echo '<li><a href="' . $file . ' " class="link_li" >' . $file . '</a></li>' . "\r\n\t";
}
}
closedir($dp);
echo '</ul> </div>';
?>
<p>... Your HTML content here ...</p>
<p>
<a href="http://validator.w3.org/check?uri=referer">validate the xhtml</a>
</p>
</body>
</html>
This script lists the files as links. You will have to Mod it to count the files and echo the results of the count. And add the CSS styling for the UL and LI's , etcetera. Not a biggie.
Reply