irkevin Posted August 25, 2009 Share Posted August 25, 2009 Hi, I'm stuck with this now. I have a field in my table call date_added I want to retrieve data from the latest date added and output it for only 5 days on a page. I can't figure out how to do this. Can someone please explain how to proceed? My query look like this: SELECT * FROM tableName ORDER BY date_added ASC But then, i Don't have a clue how to proceed with this date thing :s Quote Link to comment Share on other sites More sharing options...
deansatch Posted August 25, 2009 Share Posted August 25, 2009 Create a variable $todays_date, and another variable $five_days_later. Then you can change your query to: SELECT * FROM tableName WHERE date_added >= '$todays_date' AND date_added <= '$five_days_later' ORDER BY date_added ASC You can use mktime() to set $five_days_later Quote Link to comment Share on other sites More sharing options...
irkevin Posted August 25, 2009 Author Share Posted August 25, 2009 Thats perfect. Exactly what i needed. Thanks bro Below is the code. for those who might need it $make_date = mktime(0,0,0,date("m"),date("d")+5,date("Y")); $remove_after = date('Y-m-d',$make_date); $today = strftime('%Y-%m-%d'); "SELECT * FROM tableName WHERE date_added >= '$today' AND date_added <= '$remove_after' ORDER BY date_added ASC" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.