-3
请帮忙!获取PHP中特定列下的值总和
我想从该列所有值的一个总和,Totalamt 将Total:
下显示
有人可以帮忙与编码,因为totalamt值通过减法乘法结果得到因折扣等,不是简单地定义为$ row ['totalamt'],就像我看到其他来源是如何。
发票
<body>
<?php
if (isset($_POST['submit'])) {
$name_array = $_POST['name'];
$quantity_array = $_POST['quantity'];
$amount_array = $_POST['amount'];
$discount_array= $_POST['discount'];
for ($i =0; $i < count($name_array); $i++) {
$name = $name_array[$i];
$quantity = $quantity_array[$i];
$amount = $amount_array[$i];
$discount = $discount_array[$i];
echo "<table border='1'>\n";
echo "<tr>\n";
echo "<th>Description</th>\n";
echo "<th>Quantity</th>\n";
echo "<th>Amount($)</th>\n";
echo "<th>Discount(%)</th>\n";
echo "<th>Totalamt</th>\n";
echo "</tr>";
echo "<tr>";
echo "<td>" . $name . "</td>";
echo "<td>" . $quantity . "</td>";
echo "<td>" ."$" . $amount . "</td>";
echo "<td>" . $discount . "%" . "</td>";
echo "<td>" . "$" . ($amount - ($amount * ($discount/ 100))) * $quantity . "</td>";
echo "</tr>";
echo "total:";
}
}
?>
</body>
</html>`
你在问怎么做基础数学? – PeeHaa
好的,如果不使用SQL,是否可以将特定列中的值设置为单个变量以'echo'-ed? – user3300482