I have the following query

SELECT * from PHOTOS WHERE Subject = '$Subject' AND Location = '$Location' ORDER BY Number

It results in the following output

1, 10, 11, 12, 13, 14, 15, 2, 3, 4, 5, 6, 7, 8, 9

How does PHP/MySql think 10 is lower than 2??

This is driving me nuts, any help would be greatly appreciated.

My guess is you defined your Number field/column as Text data time instead of INT. So it is doing ascii comparisons. In the ascii table the '1' comes before the '2'. You need to change the data type of the column to INT or cast the Number:
http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html SELECT * from PHOTOS WHERE `Subject`= '$Subject' AND `Location` = '$Location' ORDER BY CONVERT(`Number`,UNSIGNED INTEGER)

Am I the only one that gets so wrapped up in the bigger issues that you forget to check the small details?

I had my boyfriend helping me set up the tables and I didn't even think to check if he followed my notes correctly.

Thanks so much, hielo...sorry for the silly question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.