我已成功展示购物车并将其添加到购物车中。 但我想在付款页面上显示购物车项目列表以便让用户 确认他们的商品数量和价格。如何在中显示这些数据 会话。这是我的编码方式。下面的代码是cart.php 我想将项目显示到payment.php
switch($action)
{
case "add":
if (isset($_SESSION['cart'][$proid]))
$_SESSION['cart'][$proid]++;
else
$_SESSION['cart'][$proid]=1;
break;
case "remove":
if (isset($_SESSION['cart'][$proid]))
{
$_SESSION['cart'][$proid]--;
if ($_SESSION['cart'][$proid]==0)
unset($_SESSION['cart'][$proid]);
}
else
$_SESSION['cart'][$proid]=1;
break;
case "empty" :
unset($_SESSION['cart']);
break;
}
if (isset($_SESSION['cart']))
{
$total = 0;
foreach($_SESSION['cart'] as $proid =>$x)
{
$results = mysqli_query($con,"Select * from product where Product_ID = $proid");
$myrow = mysqli_fetch_array($results);
$productname = $myrow['Product_Name'];
$productprice= $myrow['Product_Price'];
$line_cost = $productprice * $x;
$total=$total+$line_cost;
?>
<li class = "cartlist">
<?php echo '<img src="data:image/jpeg;base64,' . base64_encode($myrow['Product_Pic']) . '" width="196" height="120">';?>
<p><span style = "font-weight: bold; font-size: 1.2em;">
<?php echo $productname ?>
</span></br />RM <?php echo $productprice;?>
</br />Quantity : <?php echo $x ?></br><a href='cart.php?proid=<?php echo $proid;?>&action=add'>Add </a> <a href ='cart.php?proid=<?php echo $proid;?>&action=remove'> Reduce </a></br>RM<?php echo $line_cost; ?> <br/>
</p> </li>
<?php
}
?>