0
点赞
收藏
分享

微信扫一扫

韩顺平zend+framework 视频教程 笔记心得 源代码下载 第20讲+综合应用-购物车5


增加功能 :

安全退出

不同用户登录看到的用户购物车不一样

各自显示各自用户的。

//显示购物车  抽象封装某个用户的购物车
function showMyCart($userId){
$sql="select b.id,b.name,b.price,m.nums from book b,mycart m where b.id=m.bookid AND m.userid=$userId";
$db=$this->getAdapter();
$res=$db->query($sql)->fetchAll();
//顺带把总价计算出来
//$total_price=0;
for($i=0;$i<count($res);$i++){
$bookinfo=$res[$i];
$this->total_price+=$bookinfo['price']*$bookinfo['nums'];
}
return $res;
}

举报

相关推荐

0 条评论