vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Contradicting post count (https://vborg.vbsupport.ru/showthread.php?t=319176)

LethalJ 06-22-2015 01:22 PM

Contradicting post count
 
Hoping some of you great folk can assist me with this little problem I have.
We've added a profile popup to our forum for which we are calling the content from the mysql database which is working fine but it's causing a contradiction in the post count on postbit_legacy as it's including all the spam threads as well for which posts don't count. Is there anyway I can exclude these forum id's from the .php file so it only reads the correct postcount

The code to grab the postcount.php is as follows;
Code:

$grabposts = mysql_query("SELECT * FROM post WHERE userid = '" . $userid . "'");
$showposts = mysql_fetch_assoc($grabposts);
$numposts = mysql_num_rows($grabposts);
$postsamount = number_format($numposts);

Any help is appreciated

Thanks,
JB

squidsk 06-22-2015 01:53 PM

Why not just use the post count that is attached to the users profile, which will usually be accessible from, or made accessible from all locations. It will be a much faster query because you aren't going through the entire post table to search for things, and likely won't need any additional queries to make it work and it will automatically exclude all forums that don't contribute to post count.

If you really want to query the post table then use this code as it's better than what you have:

Code:

$grabposts = mysql_query_first("COUNT * AS posts FROM post WHERE userid = '" . $userid . "' AND forumid NOT IN (forumid1, forumid2, . . . .)");
$numposts = $grabposts['posts'];
$postsamount = number_format($numposts);



All times are GMT. The time now is 02:19 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.01648 seconds
  • Memory Usage 1,707KB
  • 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_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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