PDA

View Full Version : Getting total # of threads for certain forums on non vb page?


Gutspiller
07-13-2002, 11:32 PM
I have a few sections on my frontpage that I would like to show the users how many threads have been started in that forum. I need it to also be able to work multiple times on the same page though, meaning I want to show the total threads in different places and for different forums.

If you can help me with this I would really appreciate it.

Thanks!

Dean C
07-14-2002, 10:08 AM
i would like this to incluede on my portal too...

Gutspiller
07-16-2002, 04:19 AM
Bump!

Gutspiller
07-19-2002, 06:36 PM
bump

Gutspiller
07-26-2002, 04:34 AM
bump

Logician
07-26-2002, 06:13 AM
You can use the algorithm:

https://vborg.vbsupport.ru/showthread.php?postid=276926#post276926

Change the query to anything you like and it will display any info you queried in a non-vb page.

Needless to say, you need to insert this code into a page with .php extension..

Gutspiller
08-03-2002, 07:17 PM
Originally posted by Logician
You can use the algorithm:

https://vborg.vbsupport.ru/showthread.php?postid=276926#post276926

Change the query to anything you like and it will display any info you queried in a non-vb page.

Needless to say, you need to insert this code into a page with .php extension..

I put


<?

require("admin/config.php");
mysql_connect("$servername", "$dbusername", "$dbpassword") or die("Couldnt find MYSQL!");
mysql_select_db("$dbname") or die ("Couldnt find DB!");
$totalviews=mysql_query("SELECT SUM(views) AS threadviews FROM thread");
if (mysql_error()) {echo "mySQL error:"; echo mysql_error(); exit;}
else
{echo mysql_result($totalviews,0);}
?>


into my frontpage, but it only shows the totalviews. How do I change it so that it shows the total threads that have been made in a certain forum?

Gutspiller
08-03-2002, 07:57 PM
NM, I got it to work by tweaking a last 24 posts hack. Thanks anyway.

Dean C
08-04-2002, 01:28 PM
can u share the code with me please gutspiller :D?

Gutspiller
08-04-2002, 11:50 PM
OK, here's the code:


<?
$last24 = time() - 0;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost < $last24 AND (forumid = '999')"));
echo number_format($threads[total]);
?>


Slap that on a non-vb page that has a php extension and it should work. Change 999 number to the forum id that you want.

There might be an easier way and I don't know if this takes longer to do than some other way, but since I couldn't get any help. :p I had to use a work around and it works.

You can also get the total for multiple forums by doing something like this:


<?
$last24 = time() - 0;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost < $last24 AND (forumid = '143' OR forumid = '162' OR forumid = '161' OR forumid = '163' OR forumid = '145' OR forumid = '153' OR forumid = '164' OR forumid = '155' OR forumid = '167' OR forumid = '158' OR forumid = '165' OR forumid = '166' OR forumid = '127')"));
echo number_format($threads[total]);
?>

Seems to work on my front page, and it's running 12 times on my front page for different forums. If you want to see it in action you can check out www.3dNewz.com

Dean C
08-05-2002, 09:16 AM
say if i wanted to put this code on my vbportal page in a side block:


<?
$last24 = time() - 0;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost < $last24 AND (forumid = '999')"));
echo number_format($threads[total]);
?>


how would i go about doing it?

Gutspiller
08-05-2002, 08:35 PM
Originally posted by Mist
say if i wanted to put this code on my vbportal page in a side block:


<?
$last24 = time() - 0;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost < $last24 AND (forumid = '999')"));
echo number_format($threads[total]);
?>


how would i go about doing it?

I'm not sure. I've never installed vbportal before.