PDA

View Full Version : thread/post date


Haakon
05-15-2003, 08:02 PM
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
Today at 08:51 PM filburt1 said this in Post #4 (https://vborg.vbsupport.ru/showthread.php?postid=395612#post395612)
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
Yesterday at 09:04 PM Boofo said this in Post #6 (https://vborg.vbsupport.ru/showthread.php?postid=395617#post395617)
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
Today at 04:53 PM Boofo said this in Post #9 (https://vborg.vbsupport.ru/showthread.php?postid=395853#post395853)
I will pm you with the info, if it is alright. ;) Okay ;)