[SOLVED] ORDER BY problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

[SOLVED] ORDER BY problem.

Post by Dale »

Im using the

Code: Select all

ORDER BY
line in my code but for some reason, its only sorting the numbers in my databse by there first number.

eg;
My Code:

Code: Select all

$sql = "SELECT * FROM top_mybb_sites WHERE approved = 1 ORDER BY posts ASC";
Shows:

142233
152
17
2342
210
24
35
486
42

How do i get it to sort in numerical order? (eg; 17, 24, 35, 42, ect...)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

obviously you aren't storing them in integer fields.. you should be able to cast the field to integer and sort by the result.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Ah thanks it worked. :)
Post Reply