PHP+MYSQL购物车最后一天哦

<?php
//购物车页面
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>");
}
?>
<!DOCTYPE html>
<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>

	<?php
	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><?php
	header("Content-Type: text/html;charset=utf-8");
				echo  $data['id'];
			?></td><td>
				<img src="<?php
					echo $data['pic'];
				?>"width='30' height='30'>
			</td>
			<td><?php
			header("Content-Type: text/html;charset=utf-8");
				echo $data['gname'];
			?></td>
			<td><?php
			header("Content-Type: text/html;charset=utf-8");
				echo  $data['price'];
			?></td>
			<td><?php
			header("Content-Type: text/html;charset=utf-8");
				echo $data['count'];
			?></td>
			<td>
				<a href="gw2.php?act=delGood&id=<?php
						echo $data['id'];

				?>">删除商品</a>
			</td>
		</tr>
		<?php
		header("Content-Type: text/html;charset=utf-8");
			$sum+=$data['price']*(int)$data['count'];endforeach;
		?>
		<tr colspan='6'>
			<td>
				合计<?php
				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=<?php
				header("Content-Type: text/html;charset=utf-8");
						echo $data['id'];

				?>">删除所有商品</a>
			</td></tr>
				</table>
	
</body>
</html>
posted @ 2020-04-15 23:57  贵哥的编程之路  阅读(10)  评论(0)    收藏  举报