php sort array by date and sql retrieve date date_format
Posted: Thu Sep 03, 2009 2:41 pm
I'm trying to build a function that will retrieve dates from an sql table, put them into an array, sort them by date, and then echo them out in order in a different date format.
so if my table looked like this
| orderid | orderedname | orderdate_ | shipdate_ |
|___1___|Bill__________|1999-12-23|1999-12-24|
|___2___|jon__________|2004-08-20|2004-08-24|
|___3___|tod__________|2007-03-13|2007-03-26|
|___4___|Jane_________|2007-03-23|2007-03-24|
$result=myzql_query(SELECT * FROM table...);
while($row=mysql_fetch_array($result)){
$shipdate=$row[shipdate];
$orderid=$row[orderid];
$id[$shipdate]=$orderid;
}
that's the easy part now I have no idea where to start to figure out how to sort them by $shipdate and then I want to echo them out with a format of March 24, 2007
so if my table looked like this
| orderid | orderedname | orderdate_ | shipdate_ |
|___1___|Bill__________|1999-12-23|1999-12-24|
|___2___|jon__________|2004-08-20|2004-08-24|
|___3___|tod__________|2007-03-13|2007-03-26|
|___4___|Jane_________|2007-03-23|2007-03-24|
$result=myzql_query(SELECT * FROM table...);
while($row=mysql_fetch_array($result)){
$shipdate=$row[shipdate];
$orderid=$row[orderid];
$id[$shipdate]=$orderid;
}
that's the easy part now I have no idea where to start to figure out how to sort them by $shipdate and then I want to echo them out with a format of March 24, 2007