Hiya, How can I display number of images hosted on my imagehosting service somewhere on the front page? http://www.imagegrip.com Thanks in advance. Cheers
Are you tracking the uploads in a database? Or are the images just stored in a folder? Or folders? Provide more information...
Images are stored in a folder and tracking in enabled in the database as well. I am not an expert, it just in phpmyadmin, I see the same number of images which are uploaded in the upload folder. Is it of any help at all?
$query = mysql_query("SELECT COUNT(*) AS total FROM your-table"); $images = mysql_fetch_assoc($query); echo $images['total']; PHP: This should work. Make sure a MySQL connection is established when calling this script. And you'll have to replace "your-table" with the actual table name where the images are tracked.
That way would work but you could also count how many files in the directory and minus 1 for the htaccess etc. This should work the same and give the same number so you could compare these two numbers./
it would actually be - 3 for the .htaccess and . and .. but that is the wrong way to go about it. nico's method is spot on. there's no point in looping through the files in the directory and checking meta data to be sure that is in fact an image when all you have to do is a single sql query to get the total number of images.