Jump to content

[SOLVED] Show mysql Data for only Five days


irkevin

Recommended Posts

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

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

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"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.