This is a discussion on "Order By" within the PHP Forum section. This forum, and the thread "Order By are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Order By
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Order By
1 2 25 3 4 41 5 ? |
|
|
|
#2
|
||||
|
||||
|
Re: Order By
because, a computer thinks that is the proper order.
Computers put things in order by the first # and then the 2nd number etc etc. Best way to do this is to put your results into an array and then sort them using sort(array, sort type) here is a link explaining this: http://www.w3schools.com/php/func_array_sort.asp
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
|
#3
|
||||
|
||||
|
Re: Order By
You are trying to sort a string field that contains numbers, which means mysql is reading them as text. (In text, 100 comes before 11 for the same reason baa comes before bb.) If you don't want to change the column type, you can convert it to numbers by using
If you have mixed text and numbers in the field, afaik you're screwed. My solution would be to create a separate varchar field for ordering. Somebody else might have a better solution. This thread belongs in the MYSQL forum. Last edited by masonbarge; Jun 28th, 2007 at 13:33. |
![]() |
| Tags |
| sort |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP order form | DezMarker | PHP Forum | 4 | Apr 6th, 2008 22:54 |
| save order in the Mysql | mcnika | Databases | 0 | Mar 30th, 2008 08:54 |
| help with order for needed | bruno89 | Web Page Design | 21 | Oct 1st, 2006 04:38 |
| Tab Order | aje | Web Page Design | 2 | May 13th, 2006 14:49 |