keithschm Posted March 3, 2006 Share Posted March 3, 2006 ok I am quering a table that has a number of fields. one of the fields is "rank". each entry has a number in the rank field 1 through 24. I am sorting by that field. "ORDER BY rank"but instead of ordering like 1,2,3,4, etc it orders it by 1,10,11,12,13.....2,20,21,22,.....3,4,5,6,7,8,9if I sort the table trough phpmyadmin it sorts the same way as well, What am I doing wrong. Do I have to change the type of that field. it is currently a text field.thanks Link to comment https://forums.phpfreaks.com/topic/4030-order-by-help/ Share on other sites More sharing options...
obsidian Posted March 3, 2006 Share Posted March 3, 2006 [!--quoteo(post=351394:date=Mar 3 2006, 02:14 PM:name=keithschm)--][div class=\'quotetop\']QUOTE(keithschm @ Mar 3 2006, 02:14 PM) [snapback]351394[/snapback][/div][div class=\'quotemain\'][!--quotec--]Do I have to change the type of that field. it is currently a text field.thanks[/quote]welcome to the forums! i hope you get lots of help here!to get it to sort numerically, you have to have a numeric field, so, yes, you'd do better to have it as an INT field in the database. it is sorting alphabetically since it's a string, and alphabetically, the numbers are taken character by character and matched, not as a whole. Link to comment https://forums.phpfreaks.com/topic/4030-order-by-help/#findComment-13969 Share on other sites More sharing options...
keithschm Posted March 3, 2006 Author Share Posted March 3, 2006 wow thanks, that was easy. Thanks for the helpI just donated $20 to the cause. Link to comment https://forums.phpfreaks.com/topic/4030-order-by-help/#findComment-13978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.