The Little Guy Posted July 25, 2008 Share Posted July 25, 2008 I have a feed that shows the last 3 days, the info comes from a database. $twoDaysAgo = strtotime($cDate." - 2 days"); $query = "SELECT * FROM feed WHERE (`owner` = '3' AND `owner`) AND `feedDate` >= '$twoDaysAgo' ORDER BY `feedDate` DESC, `id` DESC"; How can select a limit of 5 for today, yesterday, and the day before (no matter what day it is now)? Link to comment https://forums.phpfreaks.com/topic/116612-select-5-results-from-3-days-total-of-15-results/ Share on other sites More sharing options...
fanfavorite Posted July 25, 2008 Share Posted July 25, 2008 I may be misinterpreting your question, but basically you just need to limit your results to only 5? Just add "LIMIT 5" to the end of the query string: $query = "SELECT * FROM feed WHERE (`owner` = '3' AND `owner`) AND `feedDate` >= '$twoDaysAgo' ORDER BY `feedDate` DESC, `id` DESC LIMIT 5" Link to comment https://forums.phpfreaks.com/topic/116612-select-5-results-from-3-days-total-of-15-results/#findComment-599624 Share on other sites More sharing options...
prcollin Posted July 25, 2008 Share Posted July 25, 2008 I may be misinterpreting your question, but basically you just need to limit your results to only 5? Just add "LIMIT 5" to the end of the query string: $query = "SELECT * FROM feed WHERE (`owner` = '3' AND `owner`) AND `feedDate` >= '$twoDaysAgo' ORDER BY `feedDate` DESC, `id` DESC LIMIT 5" or set up 3 different select queries one for each day and set each ones limit to 5 if you are looking for five from each day. Link to comment https://forums.phpfreaks.com/topic/116612-select-5-results-from-3-days-total-of-15-results/#findComment-599627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.