//购物车页面
error_reporting('E_ALL&~E_NOTICE');
header('content-type:text/html;charset-utf-8');
session_start();
//如果为空,证明没有物品在里面,,所以要去上一页买东西啦
if(empty($_SESSION['cart']))
{
exit("<script>alert('请先购物物品');
location.href='gw1.php';
</script>");
}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h1>购物车列表</h1>
<table>
<tr>
<td>商品编号</td>
<td>商品图片</td>
<td>商品名称</td>
<td>商品价格</td>
<td>商品数量</td>
<td>操作</td>
</tr>
error_reporting('E_ALL&~E_NOTICE');
header('content-type:text/html;charset-utf-8');
$sum=0;$i=1;
foreach ($_SESSION['cart'] as $data): {
}//cart里面的东西,一个一个遍历给$data
<tr><td>
header("Content-Type: text/html;charset=utf-8");
echo $data['id'];
</td><td>
<img src="
echo $data['pic'];
"width='30' height='30'>
</td>
<td>
header("Content-Type: text/html;charset=utf-8");
echo $data['gname'];
</td>
<td>
header("Content-Type: text/html;charset=utf-8");
echo $data['price'];
元</td>
<td>
header("Content-Type: text/html;charset=utf-8");
echo $data['count'];
</td>
<td>
<a href="gw2.php?act=delGood&id=
echo $data['id'];
">删除商品</a>
</td>
</tr>
header("Content-Type: text/html;charset=utf-8");
$sum+=$data['price']*(int)$data['count'];endforeach;
<tr colspan='6'>
<td>
合计
header("Content-Type: text/html;charset=utf-8");
echo $sum;
元|<button>支付</button>|<a href="gw1.php">返回继续购物</a>
</td>
</tr>
<tr><td>
<a href="gw2.php?act=delCart&id=
header("Content-Type: text/html;charset=utf-8");
echo $data['id'];
">删除所有商品</a>
</td></tr>
</table>
</body>
</html>