表示されたテーブルの列を合計する必要があります。私の質問:他の列からデータを計算したテーブル列を合計するにはどうすればよいですか?それを行うにはJavaScriptを使用する必要がありますか?関連する列の下部に合計を表示したいと思います。よろしくお願いします。
私の現在の計算データの例:
echo round(($r->price_sold - $r->shipping - $r->tax - $r->fees) * $r->commission_rate / 100,2);
$query = "
SELECT *
FROM jos_data_Used_Gear
ORDER BY client_name ASC
LIMIT 0, 100;
";
$db->setQuery($query);
$url = $db->loadObjectList();
echo '<table id="consignment-table" border="0" align="center" width="3000px">';
echo '<tr class="consignment-header"><th class="consignment-client">Client</th>';
echo '<th class="consignment-title">Item Name</th>';
echo '<th class="consignment-saleprice">Price Sold</th>';
echo '<th class="consignment-saleprice">Tax</th>';
echo '<th class="consignment-saleprice">Shipping</th>';
echo '<th class="consignment-saleprice">Service Fee</th>';
echo '<th class="consignment-saleprice">Commission</th>';
echo '<th class="consignment-saleprice">Due Client</th>';
if(count($url)) {
foreach($url as $r) {
echo '<tr><td nowrap="nowrap">';
echo $r->client_name;
echo '</td><td nowrap="nowrap">';
echo $r->item_title;
echo '</td><td class="currency" nowrap="nowrap">';
echo "$";
echo $r->price_sold;
echo '</td><td nowrap="nowrap">';
echo "$";
echo $r->tax;
echo '</td><td class="currency" nowrap="nowrap">';
echo "$";
echo $r->shipping;
echo '</td><td nowrap="nowrap">';
echo "$";
echo $r->fees;
echo '</td><td nowrap="nowrap">';
echo round(($r->price_sold - $r->shipping - $r->tax - $r->fees) * $r->commission_rate / 100,2);
echo '</td><td class="currency" nowrap="nowrap">';
echo "$";
echo round(($r->price_sold - $r->fees - $r->tax - $r->shipping) - (($r->price_sold - $r->fees - $r->tax - $r->shipping) * $r->commission_rate / 100) ,2);
echo "</td></tr>";
}
}
echo '</table>';