PDA

View Full Version : What querys for # of threads and posts?


Slapyo
03-09-2005, 03:29 PM
I want to put the number of threads and posts on the front of my site. I currently have something, but the numbers are off. I assume that it is because of deleted posts and threads. Below are the queries I am using.
SELECT COUNT(*) AS threads FROM thread
SELECT COUNT(*) AS posts FROM post
However, the numbers are off. On my homepage it shows:
Threads: 477
Posts: 1,531

But on the forum index page at the bottom it shows:
Threads: 463
Posts: 1,529

What are the queries that vBulletin uses to grab that information? I have been digging through the code but I can't seem to find them. I would like the numbers to match.

Zachery
03-09-2005, 03:33 PM
I want to put the number of threads and posts on the front of my site. I currently have something, but the numbers are off. I assume that it is because of deleted posts and threads. Below are the queries I am using.
SELECT COUNT(*) AS threads FROM thread
SELECT COUNT(*) AS posts FROM post
However, the numbers are off. On my homepage it shows:
Threads: 477
Posts: 1,531

But on the forum index page at the bottom it shows:
Threads: 463
Posts: 1,529

What are the queries that vBulletin uses to grab that information? I have been digging through the code but I can't seem to find them. I would like the numbers to match.
Don't forget you need to exlucde delete posts :)

Slapyo
03-09-2005, 03:35 PM
Ya, I am just not sure how to do that in the query.

Zachery
03-09-2005, 03:43 PM
Ya, I am just not sure how to do that in the query.
Take a look near the bottom of index.php :)

Slapyo
03-09-2005, 03:47 PM
great. thanks. i will look there.

ok, so the bottom of index.php had exactly what i want. the # of threads, the # of pots, and the # of users. however, i copy/paste that code into my homepage and it all comes up as 0.

i did print_r on the array and it was full of information, except it didn't have the thread or post info in it like the code says it should.

here is what the top of my file looks like.

<?php
require_once("header.inc.php");
chdir("./forums/");
require_once("./global.php");
require_once("./includes/functions_forumlist.php");
chdir("../");
require_once("latest_users.inc.php");
require_once("online.php");

// Forum Stats

$countmembers = $DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$totalmembers = vb_number_format($countmembers['users']);

// echo "<pre>";
// print_r($forumcache);
// echo "</pre>";

$totalthreads = 0;
$totalposts = 0;
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);
before that it worked, the variable names are the same. i am not sure why the array contains that information in the forums, but not when i call it outside of the forums.

still no dice. i have looked at the different files that are included. on index.php and i have the same files included on my page. but the array on my page still doesn't contain the information that is on the index.php page.

ok, so after digging through the code and seeing the query that gathers the info and stores it into an array, i ran the query myself and parsed it. still no dice. i end up with 0. it seems like the information being stored in the database doesn't contain the information. however the code on index.php says otherwise. so i am confused.

Slapyo
03-10-2005, 03:54 PM
Take a look near the bottom of index.php :)

Can't seem to get it to work. That code doesn't work when I put it on my page, even though the same files are included in index.php as on my page.

Slapyo
03-11-2005, 07:49 PM
i found out the solution. if anyone wants to know it is in my last post in this thread.

77916