NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP & MYSQL: Closest Dates

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 09-10-2006, 11:38 AM THREAD STARTER               #1 (permalink)
NamePros Member
 
dcgamers's Avatar
Join Date: Feb 2006
Location: NY, USA, Earth
Posts: 85
dcgamers is an unknown quantity at this point
 



Help! PHP & MYSQL: Closest Dates


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?
dcgamers is offline  
Old 09-10-2006, 11:56 AM   #2 (permalink)
NamePros Regular
 
NuPagady's Avatar
Join Date: Jul 2005
Posts: 483
NuPagady is on a distinguished road
 



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:
????: NamePros.com http://www.namepros.com/programming/236606-php-and-mysql-closest-dates.html
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

Good luck!
Last edited by NuPagady; 09-10-2006 at 12:16 PM.
NuPagady is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:16 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger