session_start();
include("conn/conn.php");
if($_session[username]==""){
echo "<script>alert('请先登录后购物!');history.back();</script>";
exit;
}
$id=strval($_get[id]);
$sql=mysql_query("select * from tb_shangpin where id='".$id."'",$conn);
$info=mysql_fetch_array($sql);
if($info[shuliang] echo "<script>alert('该商品已经售完!');history.back();</script>";
exit;
}
$array=explode("@",$_session[producelist]);
for($i=0;$i
echo "<script>alert('该商品已经在您的购物车中!');history.back();</script>";
exit;
}
}
$_session[producelist]=$_session[producelist].$id."@";
$_session[quatity]=$_session[quatity]."1@";
header("location:gouwu1.php");
?>
上面的count ($array)为什么还要减一啊谢谢大家
因为每次增加商品时:$_SESSION[producelist]=$_SESSION[producelist].$id."@";
$_SESSION[producelist] 的内容以 @ 结束
explode 后,$array 最后一个元素为空
因为每次增加商品时:$_SESSION[producelist]=$_SESSION[producelist].$id."@";
$_SESSION[producelist] 的内容以 @ 结束
explode 后,$array 最后一个元素为空
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号