![]() |
time/date limit in query
i'm trying to display the last threads in forumhome.
does anyone knows how can I set time/date limit in the query so it will get the latest threads in X Days \ Hours. If i dont do that it will look in the entire table that will cause an overload in the server. PHP Code:
|
$cut = time() - 60*60*X*Y;
where X is the number of hours and Y is the number of days.. You're basically counting the number of seconds (60 seconds * 60 minutes * X hours * Y days) and subsctracting from the current time so you get a date in the past.. then you'd add a condition to your query: AND thread.dateline > $cut |
can u please write down where I have to add this?
PHP Code:
|
ok I figured it out...
but one thing though $cut = 60*60*24*3; does this mean it will show the last threads in the last 3 days OR in the last 3 days+24 hours+60 min+60 sec because if i write 0*0*0*3 its not working. and also, do u know how can I get the forum name which the thread exist? what should I add.. thanks for your help! :) |
Quote:
|
to get the forum name you'll need to join the forum table USING(forumid) which is equal to ON(thread.forumid=forum.forumid)
|
Link14716 thanks for the explanation :)
rake, I'm getting database error when adding those lines I added PHP Code:
here is the code, just tell where to add the thing u wrote PHP Code:
like this is the thread title: PHP Code:
|
Zurih, did you manage to get his working.. If so, would you be kind enough to post what changes you made to the original mod?
:) |
Hi zurih,
Please note that operators like "||" and "&" are grandpa segments of code... toss them really fast and replace them with the regular used ones. :) About the time cut, this is really easy. All you have to do in your query is set a timecut, in this way you don't do a full table scan... for example: Code:
$threadbits = ''; With my example, it should take you only few minutes to adapt it to the VB3 code, as Stefan used to say in the good old days. :) Cheers. |
Thanks for the reply teck
I have couple of questions... Right now, this is my LATEST THREADES code in index.php: PHP Code:
PHP Code:
what I have to replace with your code? Thanks ! |
All times are GMT. The time now is 08:34 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:
|