vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   need help with vB variables or queries regarding new posts/daily posts (https://vborg.vbsupport.ru/showthread.php?t=69264)

Slapyo 09-09-2004 08:03 PM

need help with vB variables or queries regarding new posts/daily posts
 
i was wondering if there was a built in variable for vB that would tell you how many new posts there have been since you last visit, and how many posts there have been that day.

View New Posts (234) | Today's Posts (234)

i want something like that. now if there is a variable like $bbuserinfo or $pmbox that could give me this information that would be great. if not, could someone give me the 2 queries i would use to gather this information.

Xenon 09-09-2004 08:55 PM

nope, there isn't such a variable, as it would produce extra queries which should be avoided

the sql would be:

[sql]SELECT COUNT(postid) AS newposts FROM post WHERE dateline > $bbuserinfo[lastvisit][/sql]

Slapyo 09-09-2004 08:59 PM

ok cool, what about how to select for daily threads.

i'm not worried about extra queries because it is going on a non-vb page that only has a few so it won't be adding anything extra to the message board.

Slapyo 09-09-2004 09:13 PM

i got an error when i ran this:

PHP Code:

$countnewthreads $DB_site->query_first('SELECT COUNT(postid) AS newposts FROM post WHERE dateline > $bbuserinfo[lastvisit]');
$totalnewthreads number_format($countnewthreads['newposts']); 

Code:

Invalid SQL: SELECT COUNT(postid) AS newposts FROM post WHERE dateline > $bbuserinfo[lastvisit]
mysql error: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near '[lastvisit]' at line 1

mysql error number: 1064


Xenon 09-09-2004 09:24 PM

use doublequotes instead of single quotes and it will work :)

Slapyo 09-09-2004 09:34 PM

ok that worked thanks. now what do i change in the query to make it so it gives the count for the getdaily search?

the reason i ask is i think from looking at the database the times are stored in unix_timestamp format. but i don't think php has a unix_timestamp function, just mysql.

PHP Code:

$countnewthreads $DB_site->query_first('SELECT COUNT(postid) AS newposts FROM post WHERE dateline > $unix_timestamp'); 
$totalnewthreads number_format($countnewthreads['newposts']); 

i know that the ending of the query would be the only difference. my problem is being able to give the unix timestamp for today. like september 9 2004 0:0:0am ... just not sure how to go about that.

Slapyo 09-09-2004 11:11 PM

i think i might have it. lemme know if this is correct:

PHP Code:

$todaysdate date("d F Y");
$timetoday strtotime($todaysdate);
$countdailythreads $DB_site->query_first("SELECT COUNT(postid) AS dailyposts FROM post WHERE dateline > $timetoday");
$totaldailythreads number_format($countdailythreads['dailyposts']); 


Xenon 09-11-2004 04:11 PM

you can use the mktime() function ;)


All times are GMT. The time now is 10:02 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.01058 seconds
  • Memory Usage 1,727KB
  • 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
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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