PDA

View Full Version : Standalone Queries to Output # Members, Posts, Threads


greenhybrid
05-30-2005, 03:55 PM
I'm looking to output the number of members, posts and threads on a non-vB page. What would the appropriate queries be to catch these results?

Andreas
05-30-2005, 04:17 PM
SELECT SUM(replycount) AS posts, SUM(threadcount) AS threads FROM forum WHERE displayorder != 0 AND (options & 1)

SELECT COUNT(*) AS members FROM user

You can also use the datastore:
SELECT data FROM datastore WHERE title = 'userstats'
Unserialize this and use the array-key numbermembers.

greenhybrid
05-30-2005, 04:21 PM
Thanks... What's the datastore? Also, not sure what you mean by unserializing and the array-key... my PHP isn't that great.

Andreas
05-30-2005, 04:33 PM
Assuming that a connection has already been established (as $connection) and the correct database was selected:


$res = mysql_query($connection, "SELECT data FROM datastore WHERE title = 'userstats'") or die('Could not execute query');
$datastore = mysql_fetch_array($res) or die('Could not fetch result row');
$userstats = unserialize($datastore['data']);
echo "We have $userstats[numbermembers] members";