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 ;)

CRego3D 09-08-2002 05:08 PM

no :(

I get this error

Database error in vBulletin 2.2.5:

Invalid SQL: SELECT userid AS users,MAX(userid) AS max FROM user
mysql error: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause

mysql error number: 1140

CRego3D 09-13-2002 05:18 PM

any ideas? :)

Logician 09-13-2002 06:58 PM

Quote:

Originally posted by CRego3D
any ideas? :)
PHP Code:

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


CRego3D 09-14-2002 05:04 AM

^^^^ That gives me users = 0 :D ..

Logician 09-17-2002 07:08 AM

After adding the line, you should use this variable in your templates:
$numbersmembers['max']

CRego3D 09-17-2002 07:44 PM

tried it .. still showed "0" :(

Logician 09-18-2002 07:32 AM

If you add the line:
PHP Code:

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

to your index.php and add

PHP Code:

$numbersmembers['max'

to your forumhome template, it should work.. I tested it and it's working here..

wolfe 09-18-2002 09:21 PM

Quote:

Originally posted by Logician

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



i get this error on my index.php i use

Code:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
VBB 2.2.7

here is what i got in my index.php

Code:

// get total posts ever
$count_maxx_posts=$DB_site->query_first('SELECT postid AS posts FROM post ORDER BY postid DESC LIMIT 1' );
$count_maxx_posts=number_format($count_maxx_posts['posts']);

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


Logician 09-19-2002 08:59 AM

Quote:

Originally posted by wolfe
i get this error on my index.php i use
Code:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'

I tested your code in vb.2.2.7 and it gave me no errors and successfully give me the numbers when I put them inside the forumhome template. Make sure you use the variables ($count_maxx_threads,$count_maxx_posts) only inside the templates and make sure you dont process these variables in your php script like adding them something etc. like

$count_maxx_threads=$count_maxx_threads+1000;

also make sure you dont get the error because of any other line in your code..

I strongly believe if you use only this code in index.php and $count_maxx_threads and $count_maxx_posts in forumhome template, you will not get ant errors..

Legacy 11-30-2002 04:53 PM

NONE of this works for 2.2.8

for the MEMBERS part

have the Post counts working..need a working members count..600 members got removed acidentaly

[hhhh] 08-11-2003 12:55 AM

Can it work on v 2.30?


All times are GMT. The time now is 02:45 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.01077 seconds
  • Memory Usage 1,763KB
  • 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_code_printable
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (21)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete