Sort based on date selected??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cupaball
Forum Commoner
Posts: 85
Joined: Sun Feb 12, 2006 1:46 pm

Sort based on date selected??

Post by cupaball »

How All

How would I go about sorting results by the the date selected from a calendar?

I am assuming I need to do something like SELECT from here WHERE date = $date

but how do I get the date to store in the variable? Now that I think about it I guess the date would post to the page itself and store the variable.

Any help?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Sort based on date selected??

Post by Eran »

Sorting in SQL is done with the ORDER BY clause - http://dev.mysql.com/doc/refman/5.0/en/ ... -rows.html

Couldn't really understand the rest of your question.. :|
cupaball
Forum Commoner
Posts: 85
Joined: Sun Feb 12, 2006 1:46 pm

Re: Sort based on date selected??

Post by cupaball »

Sorry if I was unclear.

I am looking for the user to be able to select a date and only show results from the date selected.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Sort based on date selected??

Post by Chris Corbyn »

:arrow: Move to PHP Code
cupaball
Forum Commoner
Posts: 85
Joined: Sun Feb 12, 2006 1:46 pm

Re: Sort based on date selected??

Post by cupaball »

Anyone?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Sort based on date selected??

Post by Burrito »

you were right in your assumption.

Code: Select all

 
$query = "SELECT * FROM `someTable` WHERE `someDateField` = '".date("Y-m-d",strtotime($_POST['date']))."'";
 
Post Reply