The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
How about dateline?
|
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
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(). |
#6
|
||||
|
||||
Mug, the query man. Would you be interested in helping straighten out a few queries I am having problems with?
|
#7
|
|||
|
|||
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 |
#9
|
||||
|
||||
I will pm you with the info, if it is alright.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|