php购物车 如何做到商品已在购物车内的效果 5
<?phpsession_start();//接收session加入购物车if(!isset($_SESSION['car'])){$goos['id']=$_POST[...
<?php
session_start();
//接收session加入购物车
if(!isset($_SESSION['car'])){
$goos['id']=$_POST['id'];
$goos['numberitem']=$_POST['numberitem'];
$goos['size']=$_POST['size'];
$goos['color']=$_POST['color'];
$goos['money']=$_POST['money'];
$_SESSION['car'][]=$goos;
}
$a=$_POST['id'];
for($i=0; $i<count($_POST['id']); $i++){
if(in_array($a,$_SESSION['car'][$i])){
echo "购买过";
}else{
$goos['id']=$_POST['id'];
$goos['numberitem']=$_POST['numberitem'];
$goos['size']=$_POST['size'];
$goos['color']=$_POST['color'];
$goos['money']=$_POST['money'];
$_SESSION['car'][]=$goos;
}}
print_r($_SESSION);
?>
一直无法有已经购买过的效果 请问那边错误了呢? 展开
session_start();
//接收session加入购物车
if(!isset($_SESSION['car'])){
$goos['id']=$_POST['id'];
$goos['numberitem']=$_POST['numberitem'];
$goos['size']=$_POST['size'];
$goos['color']=$_POST['color'];
$goos['money']=$_POST['money'];
$_SESSION['car'][]=$goos;
}
$a=$_POST['id'];
for($i=0; $i<count($_POST['id']); $i++){
if(in_array($a,$_SESSION['car'][$i])){
echo "购买过";
}else{
$goos['id']=$_POST['id'];
$goos['numberitem']=$_POST['numberitem'];
$goos['size']=$_POST['size'];
$goos['color']=$_POST['color'];
$goos['money']=$_POST['money'];
$_SESSION['car'][]=$goos;
}}
print_r($_SESSION);
?>
一直无法有已经购买过的效果 请问那边错误了呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询