I want to sort my result form mysql by date. I use the query like this:
<?php
$date = $db->get_query("select distinct created_date from comments");
$condate = '';
for($i=0; $i < count($date); $i++)
{
$condate = $date[$i]['created_date'];
$data = $db->get_query("select id,created_date from comments where created_date='$condate' order by created_date");
?>
<table border='1' style="float: left; margin-left: 5px;">
<?php
for($j=0; $j<count($data); $j++)
{
echo '<tr><td>';
echo $data[$j]['id'] ;
echo '</td><td>';
echo $data[$j]['created_date'];
echo '</td></tr>';
}
?>
</table>
<?php
}
?>
This query produce result like this:
2009-07-10
2009-07-10
2009-08-21
2009-07-29
2009-08-15
The result is not sorted.
I want to see the result is:
2009-07-10
2009-07-10
2009-07-29
2009-08-15
2009-08-29
with separated table order by created-date.
I want to know sorting date in mysql result .In this case $condate
is variable for validate condition.The value of $condate
is all created_date in comments table. I produce this as within loop and set the value is.
Please help me!