sanfly Posted June 14, 2006 Share Posted June 14, 2006 I have the following query[code]$r2 = mysql_query("SELECT * FROM album_tracks WHERE at_album = '$aId' ORDER BY at_order") or die(mysql_error());[/code]at_order is a number, and there are 10 rows. When the results are listed, they come in the following order: 1, 10, 2, 3, 4 etc....How do I get the numbers to list properly? ie: 1, 2, 3, 4 ..... 10 Quote Link to comment https://forums.phpfreaks.com/topic/11963-order-by-numbers-in-mysql-query-solved/ Share on other sites More sharing options...
phpvolution Posted June 14, 2006 Share Posted June 14, 2006 [code]$r2 = mysql_query("SELECT * FROM album_tracks WHERE at_album = '$aId' ORDER BY at_order ASC") or die(mysql_error());[/code]ASC or DESC, I forget which way each goes =P Quote Link to comment https://forums.phpfreaks.com/topic/11963-order-by-numbers-in-mysql-query-solved/#findComment-45431 Share on other sites More sharing options...
sanfly Posted June 14, 2006 Author Share Posted June 14, 2006 Thanks for the help but 10 is still in the wrong place :( Quote Link to comment https://forums.phpfreaks.com/topic/11963-order-by-numbers-in-mysql-query-solved/#findComment-45432 Share on other sites More sharing options...
phpvolution Posted June 14, 2006 Share Posted June 14, 2006 Check your DB structure, those numbers could be stored as characters or text, that's usually the case because it looks like it's sorting that way. Make sure they are stored as integers. Quote Link to comment https://forums.phpfreaks.com/topic/11963-order-by-numbers-in-mysql-query-solved/#findComment-45435 Share on other sites More sharing options...
sanfly Posted June 14, 2006 Author Share Posted June 14, 2006 Sweet, that did the trick.Cheers :) Quote Link to comment https://forums.phpfreaks.com/topic/11963-order-by-numbers-in-mysql-query-solved/#findComment-45438 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.