[support] forum stats

Nathaniel Catchpole ncatchpole at brookehouse.ac.uk
Tue Apr 17 09:57:59 UTC 2007


Morten Holmstrup <morten <at> holmstrups.dk> writes:

 The trouble is that replies are in reality
> comments, and how do you count the comments that are restricted to the
> forums? This is a small feature, I admit, but I'm weird that way ;)
> 
> Please correct me, if I'm way off - this is my first site with Drupal
> (ammenet.dk).
> 
> Anyone know, how to accomplish this or just point me in the right
> direction?
> 

I've got a similar thing set up on our site, but up until recently we only had
comments on the forums, so there was no need to distinguish. If you've not got
forum posts displaying it may help though, and if you find out how to do it let
me know! This is straight from our php block (which is cached using blockcache
so it doesn't run every page request).

<?php


$userTotal = db_fetch_array(db_query("select count(distinct(uid)) from users"));

foreach ($userTotal as $index => $valueu) {
echo $valueu . " users,\n";
}


$postTotal = db_fetch_array(db_query("select count(distinct(nid)) from node
where type = 'forum';"));

foreach ($postTotal as $index => $value) {
echo $value . " topics and\n";
}

$commentTotal = db_fetch_array(db_query("select count(distinct(cid)) from
comments"));

foreach ($commentTotal as $index => $valuec) {
echo $valuec . " replies so far.\n";
}

?> 






More information about the support mailing list