![]() |
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 |
How about dateline?
|
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. |
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(). :) |
Quote:
|
Mug, the query man. Would you be interested in helping straighten out a few queries I am having problems with? ;)
|
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 |
Quote:
|
I will pm you with the info, if it is alright. ;)
|
Quote:
|
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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|