djfox Posted December 7, 2007 Share Posted December 7, 2007 I have a code to display items via listing their price by lowest to highest (ORDER BY sellprice ASC). Technically this works. Say we have 5 items: Item 1: 50 Item 2: 10 Item 3: 45 Item 4: 100 Item 5: 60 It displays the items like this: Item 2: 10 Item 4: 100 Item 3: 45 Item 1: 50 Item 5: 60 This is the display I want: Item 2: 10 Item 3: 45 Item 1: 50 Item 5: 60 Item 4: 100 I`ve seen other websites that can do this but I can`t figure out how to do this. Link to comment https://forums.phpfreaks.com/topic/80549-solved-straighten-out-this-order/ Share on other sites More sharing options...
trq Posted December 7, 2007 Share Posted December 7, 2007 What field type is sellprice? Link to comment https://forums.phpfreaks.com/topic/80549-solved-straighten-out-this-order/#findComment-408468 Share on other sites More sharing options...
djfox Posted December 7, 2007 Author Share Posted December 7, 2007 varchar Link to comment https://forums.phpfreaks.com/topic/80549-solved-straighten-out-this-order/#findComment-408472 Share on other sites More sharing options...
trq Posted December 7, 2007 Share Posted December 7, 2007 Theres your problem. It is sorting as expected, alphabeticaly, because your using a string type. You need to use an int type if you expect to sort numbers naturally. Link to comment https://forums.phpfreaks.com/topic/80549-solved-straighten-out-this-order/#findComment-408474 Share on other sites More sharing options...
djfox Posted December 7, 2007 Author Share Posted December 7, 2007 Oh my goodness, how stupid of me. Thanks very much for the help. Link to comment https://forums.phpfreaks.com/topic/80549-solved-straighten-out-this-order/#findComment-408486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.