如何将添加的产品计入总价?
这意味着我做了一些代码来降低一些产品的价格,但它不起作用?!
它只是在最后一个产品上打印我想成为子产品的总数
这是代码:
函数.php
function display_payers(){
$total = 0;
$category_query = query("SELECT * FROM payers WHERE payers_id " . escape_string($id) . " ");
confirm($category_query);
while ($row = fetch_array($category_query)) {
$sub = $row['price'];
$payers_id = $row['payers_id'];
$name = $row['name'];
$serial_number = $row['serial_number'];
$mobile_number = $row['mobile_number'];
$email = $row['email'];
$pass = $row['pass'];
$price = $row['price'];
$payer_photo = $row['payer_photo']; //**** */
$user_show = $row['user_show']; //**** */
$payer = <<<DELIMETER
<tr>
<td>{$payers_id}</td>
<td>{$name}</td>
<td>{$serial_number}</td>
<td>{$mobile_number},<br>{$email},<br>{$pass}</td>
<td>{$user_show}<br>
<a>
<img style="width: 80px; height="80px" src="../../resources/uploads/$payer_photo" alt="">
</a>
</td>
<td>{$price}SR<br>
</td>
<td><a class="btn btn-default btn-number" href="index.php?edit_payer&id={$row['payers_id']}"><span class="glyphicon glyphicon-edit"></span></a></td>
<td><a class="btn btn-default" href="index.php?delete_payers_id={$row['payers_id']}"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
DELIMETER;
echo $payer;
}
$_SESSION['item_totals'] = $total += $sub;
}
使用此项添加小计
$_SESSION['item_totals'] += $sub;
减去
$_SESSION['item_totals'] -= $sub_value;