Jump to content


Photo

"ORDER BY" help


  • Please log in to reply
5 replies to this topic

#1 chester600

chester600
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 27 August 2006 - 10:07 PM

Hey all!

I am quite new to php/MySQL and have hit a problem during learning them.

I have created a table in my database that holds a user_id and the users age, which looks like this:













user_idage
156
270
317
467
572
660
799
8100
998
10200


Now when I use this query in php:

$query = "SELECT user_id, age FROM members ORDER BY age DESC";

I get the following output:












user_idage
799
998
572
370
467
660
156
10200
217
8100


For some reason 200 is being treated as < 56 and 100 as < 17. Anyone have any ideas why this would be????

Thanks in advance!

Chester600  :)

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 27 August 2006 - 10:24 PM


Try this but yours should of worked.
$query = "SELECT user_id, age FROM members where age <= 200 ORDER BY age DESC";

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 27 August 2006 - 10:26 PM

What field type is age?

#4 chester600

chester600
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 27 August 2006 - 10:30 PM

What filed type is age?


It is char.

Thanks for your reply redarrow but that still gives the same output  :(

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 27 August 2006 - 10:33 PM

change char to int then try your statement.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 chester600

chester600
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 27 August 2006 - 10:48 PM

change char to int then try your statement.


Brilliant!!! Worked perfectly.....thanks  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users