|
Posted by naixn on 12/07/06 23:10
GarryJones wrote :
> I have code numbers in 2 fields from a table which correspond to month
> and date.
>
> (Month, Code number)
> Field name = ml_mna
> 1
> 2
> 3
> etc up to 12
> (Data is entered without a leading zero)
>
>
> Field name = ml_dya
> (Date, Code number)
> 1
> 2
> 3
> etc up to 31
> (Data is entered without a leading zero)
>
> I can sucessfully add a leading zero if necessary to each number after
> retrieving with select using the following....
>
> $ml_mna=mysql_result($ml_upg,$i,"ml_mna");
> $ml_mna++;
> if (strlen($ml_mna) < 2) {
> $ml_mna = '0' .$ml_mna;
> }
>
> for the month and
>
> $ml_dya=mysql_result($ml_upg,$i,"ml_dya");
> $ml_dya++;
> if (strlen($ml_dya) < 2) {
> $ml_dya = '0' .$ml_dya;
> }
>
> for the day
>
> However, I need to display the data in date order.
>
> Using "order by" the dates are sorted before I add this leading zero
> and the result is an incorrect and confusing display
>
> For instance the date of 30 5 (30 May) is displayed in the wrong place.
> (Its sorted as 1,3,4, and not 01, 04, 30).
>
> 05 01 (1st May)
> 05 30 (30th May)
> 05 04 (4th May)
>
> So how can I sort the date after selecting, after adding the necessary
> leading zeros and before displaying?
>
> Thankfull for any help in this matter
>
> Garry Jones
> Sweden
>
Try to put your dates in an array, and sort this array in PHP, since
the latter has so many sort functions ....
http://php.net/sort
--
Naixn
http://fma-fr.net
[Back to original message]
|