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
https://forums.phpfreaks.com/topic/154391-solved-sort-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.