php购物车解决办法
程序员文章站
2023-12-25 20:14:21
...
php购物车
无标题文档
}
?>
------解决方案--------------------
你想提问的是什么? 有个 编码 方式的 文本。
你把内容用相应的源码高亮显示不是更方便别人为你解决问题吗?
------解决方案--------------------
$act=$_GET[act];
$product_id=$_GET[prcid];
if($act=="add")
{
$cars_id=explode(",",$_COOKIE[buypro]);
//echo "
//exit;
foreach($cars_id as $pr_id)
{
if($pr_id==$product_id)
{
echo "";
exit;
}
}
if(empty($_COOKIE[buypro]))
{
setcookie("buypro",$product_id,time()+3600);
setcookie("buycount","1",time()+3600);
}
else
{
$newpro=$_COOKIE[buypro].",".$product_id;
$newcount=$_COOKIE[buycount].","."1";
setcookie("buypro",$newpro,time()+3600);
setcookie("buycount",$newcount,time()+3600);
}
}
//删除
if($act=="del")
{
$buy=$_COOKIE[buypro];
$cars_id=explode(",",$buy);
$buycountary=explode(",",$_COOKIE[buycount]);
$newid=array();
$carcount=array();
for($i=0;$i {
if($cars_id[$i]!=$product_id)
{
$newid[]=$cars_id[$i];
$carcount[]=$buycountary[$i];
}
}
首页 购物篮 历史记录 退出
$con = mysql_connect("localhost", "root", "");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("user",$con);
$sql="select * from produce";//查询所有商品
$rs=mysql_query($sql,$con);//执行sql语句,得到一个结果集
while($row=mysql_fetch_array($rs))//遍历结果集
{
?>
src="images/" width="123" height="121" border="0" /> | 货物名称: |
货物价格: | |
&pname=echo $row["pname"] ?>">购买 |
}
?>
------解决方案--------------------
你想提问的是什么? 有个 编码 方式的 文本。
你把内容用相应的源码高亮显示不是更方便别人为你解决问题吗?
------解决方案--------------------
$act=$_GET[act];
$product_id=$_GET[prcid];
if($act=="add")
{
$cars_id=explode(",",$_COOKIE[buypro]);
//echo "
";";
//print_r($cars_id);
//echo"
//exit;
foreach($cars_id as $pr_id)
{
if($pr_id==$product_id)
{
echo "";
exit;
}
}
if(empty($_COOKIE[buypro]))
{
setcookie("buypro",$product_id,time()+3600);
setcookie("buycount","1",time()+3600);
}
else
{
$newpro=$_COOKIE[buypro].",".$product_id;
$newcount=$_COOKIE[buycount].","."1";
setcookie("buypro",$newpro,time()+3600);
setcookie("buycount",$newcount,time()+3600);
}
}
//删除
if($act=="del")
{
$buy=$_COOKIE[buypro];
$cars_id=explode(",",$buy);
$buycountary=explode(",",$_COOKIE[buycount]);
$newid=array();
$carcount=array();
for($i=0;$i
if($cars_id[$i]!=$product_id)
{
$newid[]=$cars_id[$i];
$carcount[]=$buycountary[$i];
}
}
相关文章
相关视频