hello there,
i have 2 queries, one which i use ORDER BY to order by a text heading, however the results return no logical order. (e.g. their all over the place).
heres a brief breakdown of the code:
$query = "SELECT * FROM sections WHERE document_id = $document_id ORDER BY section_heading DESC";
$result = mysql_query($query)
or die ("This entry hasn't been found.");
while($row = mysql_fetch_array($result))
{
$section_heading = $row['section_heading'];
$section_id = $row['section_id'];
$today = date("Y-d-m");
$dateArray=explode('-',$today);
$start_date = date('Y-d-m', mktime(0, 0, 0, $dateArray[2], $dateArray[1], $dateArray[0]));
$correct_year = $dateArray[0];
$test = $dateArray[2];
//echo $test;
$current_day = date("d");
//echo $dateArray[0];
// take 6 off the month
$end_date = $test - 6;
//echo $end_date;
// if less than jan, take 1 off the year
$current_year = "2007";
if ($end_date < 10)
{
$end_date2 = "0" . $end_date;
//echo $end_date2;
}
$new_date22 = $current_year . "-" . $end_date2 . "-" . $current_day;
$today2 = date("Y-m-d");
//echo $today2;
$query2 = "SELECT * FROM fragments WHERE section_id = $section_id AND date_created BETWEEN '$new_date22 00:00:00' AND '$today2 23:59:59' ORDER BY fragment_heading DESC";
any idea? the actual database field is just a varchar.