chester600 Posted August 27, 2006 Share Posted August 27, 2006 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:[table][tr][td][b]user_id[/b][/td][td][b]age[/b][/td][/tr][tr][td]1[/td][td]56[/td][/tr][tr][td]2[/td][td]70[/td][/tr][tr][td]3[/td][td]17[/td][/tr][tr][td]4[/td][td]67[/td][/tr][tr][td]5[/td][td]72[/td][/tr][tr][td]6[/td][td]60[/td][/tr][tr][td]7[/td][td]99[/td][/tr][tr][td]8[/td][td]100[/td][/tr][tr][td]9[/td][td]98[/td][/tr][tr][td]10[/td][td]200[/td][/tr][/table]Now when I use this query in php:[code]$query = "SELECT user_id, age FROM members ORDER BY age DESC";[/code]I get the following output:[table][tr][td]user_id[/td][td]age[/td][/tr][tr][td]7[/td][td]99[/td][/tr][tr][td]9[/td][td]98[/td][/tr][tr][td]5[/td][td]72[/td][/tr][tr][td]3[/td][td]70[/td][/tr][tr][td]4[/td][td]67[/td][/tr][tr][td]6[/td][td]60[/td][/tr][tr][td]1[/td][td]56[/td][/tr][tr][td]10[/td][td]200[/td][/tr][tr][td]2[/td][td]17[/td][/tr][tr][td]8[/td][td]100[/td][/tr][/table]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 :) Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 27, 2006 Share Posted August 27, 2006 Try this but yours should of worked.[code]$query = "SELECT user_id, age FROM members where age <= 200 ORDER BY age DESC";[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted August 27, 2006 Share Posted August 27, 2006 What field type is age? Quote Link to comment Share on other sites More sharing options...
chester600 Posted August 27, 2006 Author Share Posted August 27, 2006 [quote author=thorpe link=topic=105859.msg423002#msg423002 date=1156717562]What filed type is age?[/quote]It is char.Thanks for your reply redarrow but that still gives the same output :( Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 27, 2006 Share Posted August 27, 2006 change char to int then try your statement. Quote Link to comment Share on other sites More sharing options...
chester600 Posted August 27, 2006 Author Share Posted August 27, 2006 [quote author=redarrow link=topic=105859.msg423007#msg423007 date=1156717980]change char to int then try your statement.[/quote]Brilliant!!! Worked perfectly.....thanks ;D Quote Link to comment 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.