Sorting a pair of arrays
Posted: Mon Dec 11, 2006 6:36 pm
I have put the values of 2 columns in a MySQL DB into 2 arrays using the following:
I want to sort them descendingly so the team with the highest score is array key 0 and the rest of the values descend but once I do this the scores no longer match the teams they correspond to. How am I able to get around this problem?
Regards, Stephen
Code: Select all
$query = mysql_query("SELECT *
FROM teams");
while ($res = mysql_fetch_array($query)) {
$team[$i] = $res['team'];
$score[$i] = $res['score'];
$i++;
}Regards, Stephen