strago Posted November 19, 2012 Share Posted November 19, 2012 $query = "SELECT id, title, seo, source, counter {$FROM} ORDER by `counter` DESC LIMIT {$limit}, {$records_per_page}"; spits it out like this... 2 2 14 12 1 1 How do you make it show up as 14 12 2 2 1 1 Link to comment https://forums.phpfreaks.com/topic/270892-sorting-by-desc-trouble/ Share on other sites More sharing options...
trq Posted November 19, 2012 Share Posted November 19, 2012 What data type is the counter field? Link to comment https://forums.phpfreaks.com/topic/270892-sorting-by-desc-trouble/#findComment-1393476 Share on other sites More sharing options...
strago Posted November 19, 2012 Author Share Posted November 19, 2012 `counter` varchar(256) collate utf8_unicode_ci NOT NULL default '0', I just tried changing it from ORDER by `counter` DESC to ORDER by counter + 0 DESC and that made it start sorting correctly. Link to comment https://forums.phpfreaks.com/topic/270892-sorting-by-desc-trouble/#findComment-1393479 Share on other sites More sharing options...
Psycho Posted November 19, 2012 Share Posted November 19, 2012 That makes a lot more sense than changing the counter field to a number type. Link to comment https://forums.phpfreaks.com/topic/270892-sorting-by-desc-trouble/#findComment-1393481 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.