terrypeck36 Posted December 17, 2006 Share Posted December 17, 2006 $query = "SELECT * FROM items WHERE releasedate <= gettoday() ORDER BY releasedate DESC LIMIT 0, 3";i have a page that list my 3 newest items, i release one new item a day. i would like to slow down the rotation so the 3 newest items are displayed for 1 week before the query executes again and displays the 3 newest items for another week, so items being released in the middle of the week will never be displayed. for example, on monday i would like the query to select the new releases from sat, sun and fri and display those 3 items all week until next monday when the query executes again and displays the 3 new items for another week i have played around with interval but cannot get anything to work. releasedate is a hardcoded int typecan this be done? any help would be greatly appreciated Link to comment https://forums.phpfreaks.com/topic/31020-need-to-slow-down-the-rotation-interval-of-a-date-query/ Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 The query will be run everytime someone requests the page it is on. If you want to run the query once a week and make a static page for people to request you will need to use a cron job. Link to comment https://forums.phpfreaks.com/topic/31020-need-to-slow-down-the-rotation-interval-of-a-date-query/#findComment-143128 Share on other sites More sharing options...
terrypeck36 Posted December 17, 2006 Author Share Posted December 17, 2006 thank you for your reply, so there is no way whatsoever that i can moderate the rotation within the sql query? Link to comment https://forums.phpfreaks.com/topic/31020-need-to-slow-down-the-rotation-interval-of-a-date-query/#findComment-143135 Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 You could change the gettoday() function to another function that everytime it is called gets either today (if today is a monday) or the next monday.You would use the [url=http://php.net/date]date[/url] function to do so. Link to comment https://forums.phpfreaks.com/topic/31020-need-to-slow-down-the-rotation-interval-of-a-date-query/#findComment-143139 Share on other sites More sharing options...
NovaHaCker Posted December 17, 2006 Share Posted December 17, 2006 I had a problem along this line a week or so back.I had to pipe data out from a ssh command into 5 different boxes, and quite understandably I didn't want this command to be run everytime the user hit the page.So I took the results and inserted them into what id call a cache table in the database with a timestamp, and when the user hits the page it checks the timestamps of any data, if any and if it is within the expiry time then simply use the data from there, otherwise flush the old stuff out, if any and again generate the data from the other servers.Not sure if i explained it very well, but using this method has put one of our longest loading pages on par with the rest of them, and the best thing is that it doesnt require a cron script, as it only gathers data on demand and the cache table is self maintaining. Link to comment https://forums.phpfreaks.com/topic/31020-need-to-slow-down-the-rotation-interval-of-a-date-query/#findComment-143142 Share on other sites More sharing options...
terrypeck36 Posted December 18, 2006 Author Share Posted December 18, 2006 thorpe anyway you could expand on that a little bit??? Link to comment https://forums.phpfreaks.com/topic/31020-need-to-slow-down-the-rotation-interval-of-a-date-query/#findComment-143351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.