我需要对显示表中的一列求和。我的问题:如何对已从其他列计算数据的表列求和?我需要使用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>';