vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Getting total # of threads for certain forums on non vb page? (https://vborg.vbsupport.ru/showthread.php?t=41041)

Gutspiller 07-13-2002 11:32 PM

Getting total # of threads for certain forums on non vb page?
 
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/showthrea...926#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

Quote:

Originally posted by Logician
You can use the algorithm:

https://vborg.vbsupport.ru/showthrea...926#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

PHP Code:

<?

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:

PHP 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:

PHP Code:

<?
$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


All times are GMT. The time now is 03:10 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01171 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete