forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: Vermeer on January 09, 2006, 05:07:33 pm

Title: i need the total number of pictures
Post by: Vermeer on January 09, 2006, 05:07:33 pm
Hi,
i need following:
i want a Webpage with nothing but the total number of the pictures of the gallery.
A simple sql statement and the output line for the number - but i can't php...
Who can help me?

Thanks
Vermeer
Title: Re: i need the total number of pictures
Post by: ecto on January 09, 2006, 05:33:50 pm
No error checking or anything, but it's the simplest I could come up with if you want to fetch it from "outside" of Coppermine. Maybe you'd like to check out "CPMFetch" too, there's a dedicated board here.

Code: [Select]
<?php
mysql_connect
('localhost''username''password');
mysql_select_db('database-name');
$result mysql_query("SELECT COUNT(*) FROM cpg_pictures");
$row mysql_fetch_array($result);
echo 
"<html><body>".$row[0]."</body></html>";
?>

Title: Re: i need the total number of pictures
Post by: tantley on March 29, 2007, 05:39:08 pm
Excellent bit of code...

Had to modify the query on line 4 to the current Coppermine table which was "cpg1410_pictures" instead of "cpg_pictures"....

Thanks!
Title: Re: i need the total number of pictures
Post by: tantley on March 29, 2007, 05:47:47 pm
And used the "number_format" function to insert the comma into the value as per default US format...

Just put
Code: [Select]
number_format($row[0]) between the periods of the echo statement.