vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   thread/post date (https://vborg.vbsupport.ru/showthread.php?t=52990)

Haakon 05-15-2003 08:02 PM

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

Boofo 05-15-2003 11:12 PM

How about dateline?

MUG 05-15-2003 11:47 PM

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.

filburt1 05-15-2003 11:51 PM

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(). :)

MUG 05-15-2003 11:56 PM

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

Boofo 05-16-2003 12:04 AM

Mug, the query man. Would you be interested in helping straighten out a few queries I am having problems with? ;)

Haakon 05-16-2003 07:49 AM

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

MUG 05-16-2003 07:21 PM

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 :confused:

Boofo 05-16-2003 07:53 PM

I will pm you with the info, if it is alright. ;)

MUG 05-16-2003 08:42 PM

Quote:

Today at 04:53 PM Boofo said this in Post #9
I will pm you with the info, if it is alright. ;)
Okay ;)


All times are GMT. The time now is 01:41 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.01083 seconds
  • Memory Usage 1,726KB
  • 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_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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