Php while循环中的R和
我有循环并显示这一行Php while循环中的R和,php,Php,我有循环并显示这一行 <? if ($objResult["cashier_trans_Type"]=="out" || $objResult["cashier_trans_Type"]=="debit to customer" || $objResult["cashier_trans_Type"]=="debit") { echo "0.00"; } else { echo $Dofaa=number_format($obj
<?
if ($objResult["cashier_trans_Type"]=="out" ||
$objResult["cashier_trans_Type"]=="debit to customer" ||
$objResult["cashier_trans_Type"]=="debit") {
echo "0.00";
} else {
echo $Dofaa=number_format($objResult["cashier_trans_Value"],2);
}
?>
现在我想使用while循环对所有列进行求和:$Dofaa
如何通过php实现这一点
谢谢您不需要新的循环。只需将每个
else
循环添加到总数中即可
<?
$Dofaa_total = 0; // create a total variable
...
if ($objResult["cashier_trans_Type"]=="out" ||
$objResult["cashier_trans_Type"]=="debit to customer" ||
$objResult["cashier_trans_Type"]=="debit") {
echo "0.00";
} else {
echo $Dofaa=number_format($objResult["cashier_trans_Value"],2);
$Dofaa_total += $Dofaa; // add to the total variable
}
...
echo $Dofaa_total; // echo the total variable
?>