Deathwillow Posted April 16, 2009 Share Posted April 16, 2009 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 More sharing options...
fenway Posted April 16, 2009 Share Posted April 16, 2009 Say what? Why are you doing it that way? Use mysql_fetch_assoc() to iterate through the results -- don't issue *another* query for no reason. Link to comment https://forums.phpfreaks.com/topic/154391-solved-sort-help/#findComment-811758 Share on other sites More sharing options...
Deathwillow Posted April 16, 2009 Author Share Posted April 16, 2009 Alright, So I'm still pretty new to this and I can't seem to figure out how to sort a query Looked it up in the manual and that's pretty much exactly what I wanted to do, Thanks for the help Link to comment https://forums.phpfreaks.com/topic/154391-solved-sort-help/#findComment-811762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.