I assume "number" is a column name in your table. If so, I'm also guessing that it's probably of a varchar (or some other character type) datatype. Here's why: if it's a character, then ORDER BY will sort alphabetically. The way it sorts number alphabetically is rather odd, but it makes sense in an alphabetical way.

If it is character data, then it should order like this:
1
10
11
12
13
2
3
4
...

To correct it, put a zero at the beginning of your single digits:
01
02
03
...
10
11
12

That will order it correctly. Otherwise, change the number column to type int, and it should work just fine.

Hope that answers your question, and, yes, this is more of a MySQL question. ;-)

-Ben


John Taylor-Johnston wrote:
This is probably a MySQL question, and maybe an easy question, but I'm here to learn <|:)

When I order by number, it echoes 1,2,3,4,5,6,7,8,9,10 and hten jumps to 100...199 before it comes back to 11-19. Any way of ordering that differently?

$sql = 'SELECT * FROM '.$table.' ORDER BY number desc;';

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



Reply via email to