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
Dale
Forum Contributor
Posts: 466 Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks
Post
by Dale » Wed Feb 16, 2005 6:53 pm
Im using the
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...)
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Feb 16, 2005 7:04 pm
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 » Wed Feb 16, 2005 7:14 pm
Ah thanks it worked.