Maison > Article > développement back-end > 来请问一个有关问题
来请教一个问题
咱在做一个购物车
购物车页面cart.php
<br><?php <br />define('ACCESE',1);<br>require('../init.php');<br><br>$_GET['gid'] = (int)$_GET['gid'];<br>$_GET['num'] = (int)$_GET['num'];<br><br>$goods = new goodsModel();<br>$goods->db();<br>$cart = cart::getCart();<br><br>switch($_GET['act']) {<br> //添加商品<br> case 'buy':{<br> $result = $goods->select_goods("g_id = $_GET[gid] and g_sale=1 and g_del=0");<br> $g = $goods->db->fetch_array($result);<br> //有此商品<br> if(!empty($g)) { //判断商品是否存在<br> if($g['g_no'] $type = 'error';<br> $msg = '放到购物车添加失败(可能是库存不足或者管理员私吞了)';<br> include(ROOT.'view/home/tip.html');<br> exit;<br> }<br> //商品存在<br> $cart->addItem("$g[g_id]","$g[g_name]","$g[g_price]","$_GET[num]"); //----------------------此行报错<br> } else {<br> $type = 'error';<br> $msg = '放到购物车添加失败(可能是下架、删除或者管理员私吞了)';<br> include(ROOT.'view/home/tip.html');<br> exit;<br> }<br> break;<br> }<br><br>}<br><br>$title = '购物车 - 商城系统';<br>$path = '购物车';<br>include(ROOT.'view/home/cart.html');<div class="clear"> </div>