I have a db with intergers to hold "kills" & "deaths". This is for a game,.. now I have pulled my query ,. done my math,. and came to the number I want. Question is how would I sort it by the lowest number at this point? I need it sorted by "$tt"
<?php
function ratio(){
$ratio_query = "SELECT name, SUM(death), SUM(kills) FROM `stats`,`members` WHERE `stats`.`key` = `members`.`key_hash` GROUP BY `stats`.`key`";
$ratio = mysql_query($ratio_query) or die("Kills query error:" . mysql_error());
$ratio_row = mysql_fetch_assoc($ratio);
echo "<table align=\"center\">";
echo "<tr>";
echo "<td colspan=\"2\"> <b>Kill/Death Ratio</b></td>";
echo "</tr>";
do {
$name = explode(" ", $ratio_row['key']);
foreach($name as $key){
$deaths = $ratio_row['SUM(death)'];
$kills = $ratio_row['SUM(kills)'];
$name2 = $ratio_row['name'];
//if($deaths = 0){
//$deaths = 1;}
$r = $kills/$deaths;
$t = 1/$r;
$tt = substr("$t",0,4);
echo "<tr>";
echo "<td>$name2</td><td>$tt-$deaths-$kills</td>";
echo "</tr>";}
}while($ratio_row = mysql_fetch_assoc($ratio));
echo "</table>";
}
?>