[在此处输入图片描述] [1]当我在购物卡中添加产品并降低或增加其价值时,一切正常。但是,当我想在购物卡中添加另一种产品并且要减少或增加该产品的价值时,它将更改第一个产品的价值。我不知道问题出在哪里。
$shoppingCardItem = ShoppingCardDAO::getShoppingCardItems();
foreach ($shoppingCardItem as $item) {
<tr>
<td><a href="detail.php?productId=<?php echo $item->getProductId(); ?>"><img class="card-img-top" src="./img/<?php echo $item->getProduct()->getImage(); ?>"></a></td>
<td><?php echo $item->getProduct()->getName(); ?></td>
<td class="card-text">€ <?php echo $item->getTotalExclVAT(); ?><small> (Excl. VAT)</small></td>
<td class="card-text">€ <?php echo $item->getTotalInclVAT(); ?><small> (Incl. VAT)</small></td>
<td>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="postcheck" value="true">
<input type="hidden" name="productId" value="<?php echo $item->getProductId() ?>">
<input type="button" class="value-button" id="decrease" onclick="decreaseValue()" name="decrease" value="-">
<input type="text" id="number" name="quantity" value="<?php echo $item->getQuantity(); ?>" />
<input type="button" class="value-button" id="increase" onclick="increaseValue()" name="increase" value="+">
<td><input type="submit" name="deleteShoppingCardItem" value="Delete" class="col-0.5 btn btn-danger"></td>
</form>
</td>
</tr>
// link image
[1]: https://i.stack.imgur.com/hE1k2.png