Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-09-2004, 08:03 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 09-09-2004, 08:55 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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]
Reply With Quote
  #3  
Old 09-09-2004, 08:59 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 09-09-2004, 09:13 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 09-09-2004, 09:24 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

use doublequotes instead of single quotes and it will work
Reply With Quote
  #6  
Old 09-09-2004, 09:34 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 09-09-2004, 11:11 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']); 
Reply With Quote
  #8  
Old 09-11-2004, 04:11 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you can use the mktime() function
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:48 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.03597 seconds
  • Memory Usage 2,233KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete