【发布时间】:2013-12-30 02:57:23
【问题描述】:
所以我在 mySQL 中有一个表,其中包含包含 customerID、productPrice 和数量的销售记录。我需要从每一行获取成本,然后将其编译为总成本。我需要使用一个while循环(赋值指令)来做到这一点,到目前为止我还没有运气。这是我现在的位置,感谢任何帮助
while ($record = mysqli_fetch_array($recordSet, MYSQLI_ASSOC)) {
$cost = $productPrice * $quantity
$totalCost = $totalCost + $cost
};
echo "$totalCost";
【问题讨论】:
标签: php sql arrays loops while-loop