On my main page i added the number of image files i currently host for other people. I did this by using some very simple code. You might need this to count logs or images like me. Or maybe you just want to know how many video files you have in your folder on your hosting account.
Either way, this code is very basic and simple and can be adjusted a lot further to make it even more advanced. Feel free to do just that and to let us know by leaving a comment down here.
You can add the following code anywhere you want on your page. Keep in mind that nothing has to be kept this way. Change some things, add some things. Don't just copy and paste and not learn :)
Now for the code:
<?
$d = opendir("foldername");
$count = 0;
while(($f = readdir($d)) !== false)
if(ereg('.jpg$', $f))
++$count;
closedir($d);
print "$count";
?>
As you can see there's not much to say about it. It's simple and to the point. Feel free to give suggestions by leaving a comment.
|