Jump to content

Archived

This topic is now archived and is closed to further replies.

sanfly

ORDER BY numbers in mysql query *SOLVED*

Recommended Posts

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

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
Thanks for the help but 10 is still in the wrong place :(

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.