Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2003, 08:02 PM
Haakon Haakon is offline
 
Join Date: Nov 2001
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default thread/post date

Hi, I have this small hack I need some help with.
It displays the three best(according to votes) threads of my site on the front page.

$star1=$DB_site->query_first("SELECT * FROM thread WHERE votenum >= 2 ORDER BY votetotal LIMIT 0,1");
$star2=$DB_site->query_first("SELECT * FROM thread WHERE votenum >= 2 ORDER BY votetotal LIMIT 1,1");
$star3=$DB_site->query_first("SELECT * FROM thread WHERE votenum >= 2 ORDER BY votetotal LIMIT 2,1");

eval("\$startees = \"".gettemplate("forumhome_starthreads")."\";") ;

It works, but as it is, every thread ever created qualifies. I only want those created within 50 days or so to display, but I can`t find any columns in the 'post' nor 'thread' table that displays a date. Anyone know a solution to this.

Thanks,
Haakon
Reply With Quote
  #2  
Old 05-15-2003, 11:12 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How about dateline?
Reply With Quote
  #3  
Old 05-15-2003, 11:47 PM
MUG MUG is offline
 
Join Date: Apr 2002
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How about...

<?php
$getstars = $DB_site->query("SELECT * FROM thread ".
"WHERE votenum >= 2 AND dateline > ".(time() - (60 * 60 * 24 * 50)). // 50 days
" ORDER BY votetotal LIMIT 3");

for($i = 1; $i < 4; $i++) {
${"star$i"} = $DB_site->fetch_array($getstars);
}

$DB_site->free_result($getstars);

eval("\$startees = \"".gettemplate("forumhome_starthreads")."\";") ;
?>

I haven't tested this though.
Reply With Quote
  #4  
Old 05-15-2003, 11:51 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's by far a cleaner way, although you should never SELECT * for performance reasons (it's also just bad practice).

You might have to eval that assignment though because the variable name is freaky.

Hint: to convert a dateline to a readable date and time, read about vbdate().
Reply With Quote
  #5  
Old 05-15-2003, 11:56 PM
MUG MUG is offline
 
Join Date: Apr 2002
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 08:51 PM filburt1 said this in Post #4
You might have to eval that assignment though because the variable name is freaky.
${"star$i"} should work fine... it's perfectly valid.
Reply With Quote
  #6  
Old 05-16-2003, 12:04 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Mug, the query man. Would you be interested in helping straighten out a few queries I am having problems with?
Reply With Quote
  #7  
Old 05-16-2003, 07:49 AM
Haakon Haakon is offline
 
Join Date: Nov 2001
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for all the help!
I guess I was looking for a vbdate() function, but I think I`ll go with the solution without conversion as Mug explained.

I`ll select more specificly if it has something to it.

Thanks!
Haakon
Reply With Quote
  #8  
Old 05-16-2003, 07:21 PM
MUG MUG is offline
 
Join Date: Apr 2002
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Yesterday at 09:04 PM Boofo said this in Post #6
Mug, the query man. Would you be interested in helping straighten out a few queries I am having problems with?
Uh... sure
Reply With Quote
  #9  
Old 05-16-2003, 07:53 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I will pm you with the info, if it is alright.
Reply With Quote
  #10  
Old 05-16-2003, 08:42 PM
MUG MUG is offline
 
Join Date: Apr 2002
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 04:53 PM Boofo said this in Post #9
I will pm you with the info, if it is alright.
Okay
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 07:25 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.04715 seconds
  • Memory Usage 2,249KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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