Try these:
`/* SQL Counting Functions */
function show_subalbum_count() {
$sql = "SELECT COUNT(id) FROM ". prefix("albums") ." WHERE parentid <> \"NULL\"";
$result = query($sql);
$count = mysql_result($result, 0);
echo $count;
}
function getIDforAlbum() {
if(!in_context(ZP_ALBUM)) return false;
global $_zp_current_album;
return $_zp_current_album->getAlbumID();
}
function show_sub_count_index() {
$id = getIDforAlbum();
$sql = "SELECT COUNT(*) FROM ". prefix("albums") ." WHERE parentid = $id";
$result = query($sql);
$count = mysql_result($result, 0);
echo $count;
}`
Put these in a customfunctions.php file in your theme directory, and then you should be able to call those functions wherever it suits you. I used them on my gallery (http://www.bushwoodworking.com/zenphoto). Keep in mind you need to be careful of context (i.e. album, index, image - that sort of thing.)
You can also use the built in functions `getNumAlbums()` as well.
Here's the footer line of code I use for all my pages to show a summary list of the stats of my site:
`Albums: <?php $albumNumber = getNumAlbums(); echo $albumNumber ?> · SubAlbums: <?php show_subalbum_count(); ?> · Images: <?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?> · Comments: <?php $commentsArray = query_single_row("SELECT count(*) FROM ".prefix('comments')." WHERE inmoderation = 0"); $commentsNumber = array_shift($commentsArray); echo $commentsNumber ?>`
Hope that helps.