<?php
session_start();
print '<h1>Your Shopping Cart:</h1>';
print '<h4>The Product ID: '.$_SESSION['id'].' </h4>';
print '<h4>The Quantity: '.$_SESSION['quantity'].' </h4>';
$dbc = mysql_connect('127.0.0.1', 'root', '');
mysql_select_db('product', $dbc);
$query = "SELECT * FROM prod WHERE id='".$_SESSION['id']."'";
if ($r = mysql_query($query, $dbc)) {
while ($row = mysql_fetch_array($r)) {
print "<p><b>Product Name: {$row['name']}<br />
The Price: {$row['price']}<br />
Shipping Cost: {$row['shipping']}<br />
</p><hr />\n";
}}
?>
此代码用于带有 Session 的购物车,但问题是它只保留一种产品。
例如,如果您购买产品 A 并在购物车中删除产品 B 然后添加产品请帮助我我想添加多个产品并打印在屏幕上##