购物车满100减2元,200减5元 300减7元,php这个代码怎么写,脑壳都想破...|【高分】急求用php写的购物车代码!!!(十万火急)如果您提供的好用还有...

bczs259b

时间 2024年6月21日 预览 5

专业编程培训机构——完成蜕变以后轻松拿高薪

电话+V: 152079-09430 ,欢迎咨询php简易购物车源代码,[python实用课程],[C++单片机原理],[C#网站搭建],[Nodejs小程序开发],[ios游戏开发],[安卓游戏开发],[教会用大脑用想法赚钱实现阶层跨越]

一、购物车满100减2元,200减5元300减7元,php这个代码怎么写,脑壳都想破...

$count_price=多少钱;//购物车总金额

if($count_price>=100$count_price<200)

{

$count_price=$count_price-2;

}elseif($count_price>=200$count_price<300){

$count_price=$count_price-5;

}elseif($count_price>=300){

$count_price=$count_price-7;

二、求用thinkphp做的购物车!最好有注释!急!~~~

去网上搜个购物车类吧

三、【高分】急求用php写的购物车代码!!!(十万火急)如果您提供的好用还有...

我也要弄一个这种购物车,

我去写个,贴出来,【嘿嘿,今天上午新写的】。

我懒得新建数据库,用的是我的数据库。

你按照我的改一下就能用了

本人水平有限,高手请指正。

你,大,爷的,虽然不咋地,保证能用

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

经过调试,

//$my->add_cart(45,3,"茶几系列");//新增购物

//$my->updata_cart(13,13,8);//更新购物

//$my->del_cart(12,5,'Guest');//删除一种购物

//$my->empty_cart('Guest');//清空购物车

$ok=$my->get_cart('Guest');//返回购物车

这些都可用

-------------------------------------------------------------------

<?php

classCart

{

public$totalCost=0;//商品总金额

functioncart($host,$usr,$pwd,$db)

{

mysql_connect($host,$usr,$pwd)ordie(mysql_error);

mysql_select_db($db)ordie(mysql_error);

mysql_query("SETNamesGBk");

//只要有人访问,就自动清除一天前所有没付款的订单;

$sql="deleteFROMshopcartWHERETO_DAYS(NOW())-TO_DAYS(ptime)>=1andpayment=0";

mysql_query($sql);

}

//弹出提示

functionalter($Str,$Url)

{

echo"<Scriptlanguage='JavaScript'>alert('".$Str."');</Script>";

echo"<metahttp-equiv=refreshcontent=0;URL=".$Url.">";

}

//增加购物;三个参数:pid:产品ID,ptl:产品数量,pcid:产品类别

//查询数据库,是否存在此人在本日内订过本产品

//如果订过,那么数量累加,否则插入一个数据库行

functionadd_cart($pid,$ptl=1,$pcid)

{

if($ptl>=100||$ptl<=0)

{

$this->alter("最多买99件,最少1件","index.php");

die();

}

if(!$_SESSION['usr']){$usr='Guest';}

else{$usr=$_SESSION['usr'];}

$sql="select*fromshopcartwherepid='".$pid."'andusr='".$usr."'andpcid='".$pcid."'";

$ex=mysql_query($sql);

$ex1=mysql_fetch_array($ex);

if(!$ex1)

{

$sql="select*fromproductwhereID='".$pid."'andclass1='".$pcid."'";

$ok=mysql_query($sql);

$rs=mysql_fetch_array($ok);

if($rs)

{

$totalCost=$rs['Price']*$ptl;

$sql="insertintoshopcart(usr,pid,pname,ptl,price,pcid,psum,payment)Values(";

$sql.="'".$usr."',";

$sql.="'".$rs['ID']."',";

$sql.="'".$rs['Name']."',";

$sql.="'".$ptl."',";

$sql.="'".$rs['Price']."',";

$sql.="'".$rs['Class1']."',";

$sql.="'".$totalCost."',";

$sql.="'0')";

mysql_query($sql)ordie(mysql_error());

if($ok){$this->alter("购物成功","index.php");}

else{$this->alter("购物失败","index.php");}

}

else

{

$this->alter("不存在的商品,或者参数错误","index.php");

die();

}

}

else

{

$sql="updateshopcartsetptl=ptl+1,psum=psum+pricewhereID='".$ex1['ID']."'";

mysql_query($sql);

$this->alter("更新数量成功","index.php");

}

}

//更新购物车的单个产品的数量;

funct

Copyright2023未知推广科技
拨打电话拨打电话
Copyright2023未知推广科技