我无法得到总值,它显示为0.任何人都可以帮我处理这部分代码。
while($test = mysql_fetch_array($result))
{
$customer_id= $test['customer_id'];
$total = ($test['price']*$test['qty']);
echo "<tr>";
echo "<td>". $test['name']. "</td>";
echo "<td>". $test['email']. "</td>";
echo "<td>". $test['p_num']. "</td>";
echo "<td>". $test['address']. "</td>";
echo "<td>". $test['message']. "</td>";
echo "<td>". $test['ord']. "</td>";
echo "<td>". $test['price']. "</td>";
echo "<td>". $test['qty']. "</td>";
echo "<td>". $total. "</td>";
echo "<td>". $test['ord_date']. "</td>";
答案 0 :(得分:1)
如果price或qty为0,则检查每个循环的价格和数量值,它将返回0;
您需要对所有迭代值求和
$total += ($test['price']*$test['qty']);