私は現在、データベースからデータを取得し、その一部を計算してからテーブルに出力するコードを持っています。ただし、印刷された数字を大きいものから小さいものへと並べたいと思います。クエリでの順序付けには精通していますが、クエリは最終結果がどうなるかわかりません。このデータを再配置する最も効率的な方法は何でしょうか。
<?php
$hourAmount = $mlYeild * (3600 / $cycleTime);
$oreVolumePriceQuery = "SELECT od.oreID, od.inGameID, od.size, ir.officialCorpRate FROM oreData od JOIN itemRates ir ON od.inGameID = ir.typeID order by od.oreID asc";
$oreVolumePriceResult = mysql_query($oreVolumePriceQuery);
$hourYeild = $mlYeild * (3600 / $cycleTime);
?>
<TABLE>
<TR>
<TD><h1>Ore</h1></TD>
<TD><h1>Hourly Yeild</h1></TD>
<TD><h1>Hourly Sale</h1></TD>
</TR>
<?php
$ores = array();
While($row = mysql_fetch_assoc($oreVolumePriceResult)){
$inGameID = $row['inGameID'];
$volume = $row['size'];
$rate = $row['officialCorpRate'];
$name = $row['name'];
$hourlyYeild = $hourAmount/$volume;
$hourlyIncome = $hourlyYeild * $rate;
echo "<TR>";
echo "<TD>".$name."</TD>";
echo "<TD>".$hourlyYeild."</TD>";
echo "<TD>".$hourlyIncome."</TD>";
echo "</TR>";
}
?>
</TABLE>
要するに、入ってくるデータから、$hourlyIncome desc