vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   hack to show the total posts/threads ever not just the totals in the database now? (https://vborg.vbsupport.ru/showthread.php?t=38411)

jamie 05-08-2002 09:18 AM

hack to show the total posts/threads ever not just the totals in the database now?
 
hello,

proably a simple thing but on my board lots of threads have been pruned. So on the forum home page is there anyway to show the total posts/threads ever posted not just the totals in the database now?

just so we don't miss out on the 500'000th post :o

Logician 05-08-2002 12:14 PM

In index.php, changing the line:
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');

to:

$countposts=$DB_site->query_first('SELECT postid AS posts FROM post ORDER BY postid DESC LIMIT 1' );

and line:
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');

to:

$countthreads=$DB_site->query_first('SELECT threadid AS threads FROM thread ORDER BY threadid DESC LIMIT 1');

should do the trick! ;)

Enjoy! \\=^))
Logician

SFishy 05-09-2002 03:54 AM

What if you already pruned and did the damage? How can you restore the count?

Ideas?

Thanks!

Logician 05-09-2002 05:51 AM

@sFishy: The code above works and reliable even if you delete ALL records in your WHOLE database.. ;)

The logic that lies behind is that:

Your database tables give an id number to all records while saving them. This unique id number will be increased by 1 with every new record and since it's unique, even if you delete the record, same id # will never be assigned to a new record.

The original vbulletin code above counts the existing (undeleted) database records while calculating the message and threads numbers. However my code checks what the largest id number is in the table. If, say, it returns 4567, you are very likely to have less messages in your database, since some can be deleted in the past, but you can be sure that from day one to today, you created exactly 4567 threads whether some deleted or some exists.

See? ;)

Regards,
Logician

RDX1 05-09-2002 07:09 AM

any way so it can be like this

Threads: XXX | Posts: xxx | Total Posts: XXX

Logician 05-09-2002 08:36 AM

Quote:

Originally posted by NerdNations
any way so it can be like this

Threads: XXX | Posts: xxx | Total Posts: XXX

Sure, why not:

Leave the original code as it is and add these 2 lines after them:

$count_maxx_posts=$DB_site->query_first('SELECT postid AS posts FROM post ORDER BY postid DESC LIMIT 1' );

$count_maxx_threads=$DB_site->query_first('SELECT threadid AS threads FROM thread ORDER BY threadid DESC LIMIT 1');

Now you can change your main page template and use these 2 variables $count_maxx_posts and $count_maxx_threads in anywhere or in any way you like..

Logician

Admin 05-09-2002 09:30 AM

Logician: Just use [minicode]MAX(postid) AS maxpostid[/minicode], no need for the [minicode]ORDER BY[/minicode] and [minicode]LIMIT[/minicode].

jamie 05-21-2002 10:43 AM

thanks :) works great..not sure what firefly is on about (a better way to do it or something, but it went right over my head..) :)

CRego3D 08-31-2002 09:53 PM

this worked GREAT .. is there a way to do it to the USERS as well ?

NTLDR 08-31-2002 09:57 PM

Change in index.php:

PHP Code:

$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user'); 

To:

PHP Code:

$numbersmembers=$DB_site->query_first('SELECT userid AS users,MAX(userid) AS max FROM user'); 

That should do the job ;)


All times are GMT. The time now is 01:37 AM.

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.01041 seconds
  • Memory Usage 1,737KB
  • 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
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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