poleposters Posted July 25, 2009 Share Posted July 25, 2009 Hi, I'm wrting a blog script. Alongside each blog entry I want to display links to 5 other entries which are closest to the date of the current entry. ie, if the entry being viewed is for the 18th of January. I want to display the five previous entries.13th,14th,15th,16th and 17th of January. Is this possible? can someone point me in the right direction? Thanks. Link to comment https://forums.phpfreaks.com/topic/167369-selecting-records-based-on-date/ Share on other sites More sharing options...
Zyx Posted July 25, 2009 Share Posted July 25, 2009 You can use row identifiers and a simple WHERE clause: SELECT * FROM entries WHERE id < 10 LIMIT 5 In the WHERE clause, you put the ID of the current row - the identifiers are incrementing with each new entry, so they represent the entries in the chronological order, too. If for some reason this cannot be used, you can simply replace "id" with entry date, and this will also work. Link to comment https://forums.phpfreaks.com/topic/167369-selecting-records-based-on-date/#findComment-882532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.