Jump to content

ORDER BY problems


adamhhh

Recommended Posts

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.