Chris,
It looks like your data in date_year is not in a format that supports a
simple DESC sort.  Look into getting the column formatted in yyyy-mm-dd
order (see the mysql manual for this).  Read the data in your column, format
it, pump it back into the database, then change the column type to 'date'.
Of course, you'll also need to examine any new inputs and get them correctly
formated before they're added to the database.
hugh
----- Original Message -----
From: "EastLothianDirectory" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 02, 2004 11:18 AM
Subject: [PHP] Help for code to 'sort list' please


> I have the following sql query in my Php code:
>
> $sql = "SELECT id, date_day, date_month, date_year, title, content FROM
$table_name
> ORDER BY date_year desc";
>
> The rest of the php code is just a simple db connection with a bullet list
> and 'while' loop with an 'echo result' request.
>
> This shows a list of dates with latest year on top of list.
> I have  Select/Option boxes to chose day,month,year etc to fill in Php
form
> to update database.
>
> This is result of sql query:
>
>    2-August-2007
>   1-January-2007
> 30-December-2007
>      8-July-2006
> 29-February-2006
>     3-March-2006
> 16-February-2005
>   1-January-2004
>
> Although it lists in year order descending (in fact what I asked it to do)
> I would like to learn to sort the months and days into desc order properly
too.
>
> Can anyone suggest how I achieve this with php code.
>
> Thank you in advance
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to