Jump to content

[SOLVED] Sort help:


Deathwillow

Recommended Posts

Alright, So I'm still pretty new to this and I can't seem to figure out how to sort a query, but at the same time still get the list of things I need without using the ID... Having attempted to type this out now, I realize it's pretty hard to explain, here's the code:

 

$result = mysql_query("SELECT * FROM `wow_character` ORDER BY `RANK` ASC");
$totalMembers = mysql_num_rows($result);
$x = 1;
while ($x < $totalMembers) {
echo $x . " - ";
$sql = "SELECT * FROM wow_character WHERE ID='" . $x . "'";
$sql = mysql_query($sql);
$row = mysql_fetch_array($sql);
echo $row['RANK'] . "<br>";
$x++;
}
mysql_close($connection);

 

 

I think most of you can see where I go wrong, I get the information sorted, then I unsort it while I'm getting the information from each row... but I really don't know of another way of getting the information from the table in the order I want, hopefully you guys will know what I mean.

(PS: the 2 echos were just for me to see what the order I was getting them as)

 

ALSO note that more than one people have the same rank.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.