php实现产品加入购物车功能(1)(2)

<h2>购物车中有以下商品:</h2> <table cellpadding="0" cellspacing="0"> <tr> <td>商品名称</td> <td>商品单价</td> <td>购买数量</td> <td></td> </tr> <?php session_start(); //$uid=$_SESSION["uid"]; $arr=array(); if(!empty($_SESSION["gwc"])) { $arr=$_SESSION["gwc"]; } include("DADB.class.php"); $db=new DADB(); foreach($arr as $v) { global $db; $sql="select * from fruit where ids='{$v[0]}'"; $att=$db -> Query($sql,1); foreach($att as $n) { echo"<tr> <td>{$n[1]}</td> <td>{$n[2]}</td> <td>{$v[1]}</td> <td><a href='shanchu.php?ids={$v[0]}'>删除</a></td> </tr>";} } ?> </table> <div> <a href="https://www.jb51.net/gouwuche.php" >查看购物车</a> <a href="https://www.jb51.net/main.php" >浏览商品</a> <a href="https://www.jb51.net/zhanghu.php" >查看账户</a> </div> 14 15 </body>

这样进入购物车页面显示如图所示:

这只是比较简单的加入购物车,但是中间还有很多环节没有完善好,比如说加入购物车后,数据库中的产品数量减少、购物车中产品的删除等操作还没有做,后续补上

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/3668b0e4420d44627888e840af3abf03.html