How would I display all the data in a table where the date field is within 10 days above the current date? Im tring to display all dates within the next 10 days. How can I do that with php & mysql?
The views expressed on this page by users and staff are their own, not those of NamePros.
So basicly you need to know two variables: today's date and date after 10 days.
Try adding this to WHERE clause:
Code:
... WHERE date > ADDDATE(CURRENT_DATE(), 0) AND date <= ADDDATE(CURRENT_DATE() , 10)
'date' is your date field.
Another way would be something like that:
Code:
$tendays = 60*60*24*10 // how many seconds in 10 days
$datenow = date("Y-m-d");
$date10 = date("Y-m-d", time() + $tendays); // this will be your date (10 days after)
Change Y-m-d to your date format. You can find information on how to do that here: http://www.php.net/date
Then put date variables to your WHERE clause. Something like: ... WHERE date > $datenow and date <= $date10
I haven't checked the code for errors, I just wrote it. I hope this will be enough to get a general idea