im trying to get some ids from a db table, then do some further queries which then determines some values stored in variables. I would then like to order my sql results based on those variables.
Here is the code, ive tried to document as much as possible to give you an idea...
Code: Select all
//i firstly need to get the ids of each team playing in the league and division (variables set in url)
$getclans = mysql_query("SELECT clan_id FROM clans_div WHERE league_id = $league AND div_id = $div");
while ($myrow = mysql_fetch_array($getclans)){
$clan = $myrow["clan_id"];
//these are functions to find out the results of matches from a fixtures table, they work fine and not a problem
$played = ClanPlayed($clan); // i.e played 4
$won = ClanWin($clan); // i.e won 2
$lost = ClanLost($clan); // i.e lost 1
$drawn = ClanDraw($clan); // i.e Drawn 1
$points = ($won * 3 + $drawn * 1); // i.e points 7
//i need to order these results based on the above variables, at the moment they are ordering by the first sql query, the data contained is correct, but the ordering incorrect.
echo "<a href=\"index.php?view=leagues&clan=$clan\">$clan</a> Played $played Won $won Lost $lost Drawn $drawn Points $points<br>";
}Any ideas of how to do this woul dbe greatly appreciated.
Thanks
Phase