Jump to content


Photo

MySQL Problem 1


  • Please log in to reply
6 replies to this topic

#1 ShanesProjects

ShanesProjects
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 10 October 2006 - 08:05 PM

I got 4 users and there ranks are 1, 2, 3, and 14. Why dose this show it User1-User14-User2-User3 instead of User1-User2-User3-User14?

$sql3="SELECT * FROM guild_members WHERE Disabled='0' ORDER BY Rank DESC";


#2 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 08:12 PM

Just add some zero's in the front. It will not display on your page but will put it in order.
The system looks first for all the one's and then go for all the two's ect.
like
1
11
111
1111
2
22
222
2222

if you put the zeros in the front it will pick it up as
0001
0002
0011
0022
0111
0222
1111
2222

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 October 2006 - 08:13 PM

the rank is being sorted as a string rather than an integer. what is your datatype of your "Rank" column?
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 ShanesProjects

ShanesProjects
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 10 October 2006 - 08:17 PM

Its varchar(250).

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 October 2006 - 08:18 PM

Its varchar(250).


since it is varchar, you'll need to do some sort of padding or adjustment as gremlin suggested. do your values contain the digits only, or is the actual string "user1" your value?
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 ShanesProjects

ShanesProjects
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 10 October 2006 - 08:20 PM

What can I change it to for it to work?

#7 ShanesProjects

ShanesProjects
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 10 October 2006 - 08:22 PM

Fixed it! Changed it to int. Thanks anyways.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users