购物车php 购物车完整实现代码

php购物车  时间:2021-02-09  阅读:()

php购物车完整实现代码

本文介绍一个php实现的购物车代码功能实现比较完整实现了购物车、订货人信息、会员价等功能还是不错的有需要的朋友可以参考下

1、商品展示页面

复制代码代码如下:

<tablewidth="255"border="0" cel lspacing="0" cel lpadding="0">

<tr>

<td width="130" rowspan="6"><div al ign="center">

<?phpif(trim($info[tupian]==""))

{echo"暂无图片";

}else

{

?>

< imgsrc="<?php echo$info[tupian];?>"width="130"height="100"border="0"><?php

}

?>

</div></td>

<td width="20" height="16"></td>

<td width="113"><font color="EF9C3E"> 【<?php echo$info[mingcheng];?>】</font></td></tr>

<tr>

<td height="16"></td>

<td><font color="910800"> 【市场价 <?php echo$info[shichangji a];?>】</font></td></tr>

<tr>

<td height="16"></td>

<td><font color="DD4679"> 【会员价 <?php echo$info[huiyuanjia];?>】</font></td></tr>

<tr>

<td height="16"></td>

<td> 【<a href="lookinfo.php?id=<?php echo

$i nfo[id];?>">查看信息</a>】</td></tr>

<tr>

<td height="16"></td>

<td> 【<a href="addgouwuche.php?id=<?phpecho$i nfo[id];?>">放入购物车</a>】</td></tr>

<tr>

<td height="16"></td>

<td><font color="13589B"> 【剩余数量<?phpif(($info[shul iang]-$info[cishu])>0)

{echo($info[shul iang]-$info[cishu]);

}else

{echo"已售完";

}

?>】</font></td>

</tr>

</table>

<?php

}

?>

</table>

2、文件addgouwuche.php

复制代码代码如下:

<?phpsession_start();include("conn.php");

if($_SESSION[username]=="")

{echo"<script>alert('请先登录后购

物!');history.back();</script>"; exit;

}

$id=strval($_GET[id]);

$sql=mysql_query("select * from shangpin whereid='".$id."'",$conn); $info=mysql_fetch_array($sql);if($info[shul iang]<=0)

{echo"<script>alert('该商品已经售

完!');history.back();</script>";exit;

}

$array=explode("@",$_SESSION[producel ist]);for($i=0;$i<count($array)-1;$i++)

{if($array[$i]==$id)

{echo"<script>alert('该商品已经在您的购物车中!');history.back();</script>";exit;

}

}

$_SESSION[producel ist]=$_SESSION[producel ist].$id."@";

$_SESSION[quatity]=$_SESSION[quatity]."1@";header("location:gouwu1.php");

?>

3、文件gouwu1.php

复制代码代码如下:

<?phpsession_start();if($_SESSION[username]=="")

{echo"<script>alert('请先登录后购

物!');history.back();</script>";exit;

}

?>

<?phpinclude("top.php");

?>

<tablewidth="800" height="438"border="0" al ign="center"cel lpadding="0" cel lspacing="0"><tr>

<td width="200" height="438"val ign="top"

bgcolor="#E8E8E8"><div al ign="center">

<?phpinclude("left.php");?>

</div></td>

<td width="10"background="images/l ine2.gif"></td>

<td width="590"val ign="top"><tablewidth="550" height="10"border="0" al ign="center" cel lpadding="0" cel lspacing="0">

<tr>

<td></td>

</tr>

</table>

<tablewidth="500"border="0"al ign="center" cel lpadding="0"cel lspacing="0">

<form name="form1"method="post" action="gouwu1.php">

<tr>

<td height="25"bgcolor="#555555"><div al ign="center"style="color:#FFFFFF"><?php echo$_SESSION[username];?>的购物车</div></td>

</tr>

<tr>

<td bgcolor="#555555"><tablewidth="500"border="0"al ign="center" cel lpadding="0" cel lspacing="1">

<?php

session_start();session_register("total");if($_GET[qk]=="yes")

{

$_SESSION[producel ist]="";

$_SESSION[quatity]="";

}

$arraygwc=explode("@",$_SESSION[producel ist]);

$s=0;for($i=0;$i<count($arraygwc);$i++)

{

$s+=intval($arraygwc[$i]);

}if($s==0)

{echo"<tr>";echo"<td height='25' colspan='6'bgcolor='#FFFFFF' al ign='center'>您的购物车为空!</td>";echo"</tr>";

}else

{

?>

<tr>

<td width="125" height="25"bgcolor="#FFFFFF"><dival ign="center">商品名称</div></td><td width="52"bgcolor="#FFFFFF"><div al ign="center">数量</div></td>

<td width="64"bgcolor="#FFFFFF"><div al ign="center">市场价</div></td>

<td width="64" bgcolor="#FFFFFF"><div al ign="center">会员价</div></td>

<td width="51"bgcolor="#FFFFFF"><div al ign="center">折扣</div></td>

<td width="66"bgcolor="#FFFFFF"><div al ign="center">小计</div></td>

<td width="71"bgcolor="#FFFFFF"><div al ign="center">操作</div></td>

</tr>

<?php

**

*购物车商品数量管理

* Edit www.jb51.net

*/

$total=0;

$array=explode("@",$_SESSION[producel ist]);$arrayquatity=explode("@",$_SESSION[quatity]);whi le(l ist($name,$value)=each($_POST))

{for($i=0;$i<count($array)-1;$i++)

{if(($array[$i])==$name)

{

$arrayquatity[$i]=$value;

}

}

}

$_SESSION[quatity]=implode("@",$arrayquatity);for($i=0;$i<count($array)-1;$i++)

{

$id=$array[$i];

$num=$arrayquatity[$i];if($id!="")

{

$sql=mysql_query("select * from shangpin whereid='".$id."'",$conn);

$info=mysql_fetch_array($sql);

快云科技:夏季大促销,香港VPS7.5折特惠,CN2 GIA线路; 年付仅不到五折巨惠,续费永久同价

快云科技怎么样?快云科技是一家成立于2020年的新起国内主机商,资质齐全 持有IDC ICP ISP等正规商家。我们秉承着服务于客户服务于大众的理念运营,机器线路优价格低。目前已注册用户达到5000+!主营产品有:香港弹性云服务器,美国vps和日本vps,香港物理机,国内高防物理机以及美国日本高防物理机!产品特色:全配置均20M带宽,架构采用KVM虚拟化技术,全盘SSD硬盘,RAID10阵列, 国...

digital-vm$80/月,最高10GDigital-VM1Gbps带宽带宽

digital-vm在日本东京机房当前提供1Gbps带宽、2Gbps带宽、10Gbps带宽接入的独立服务器,每个月自带10T免费流量,一个独立IPv4。支持额外购买流量:20T-$30/月、50T-$150/月、100T-$270美元/月;也支持额外购买IPv4,/29-$5/月、/28-$13/月。独立从下单开始一般24小时内可以上架。官方网站:https://digital-vm.com/de...

IMIDC(rainbow cloud):香港/台湾/日本/莫斯科独立服务器特价,闪购大促销,最低30usd/月起

imidc怎么样?imidc彩虹网路,rainbow cloud知名服务器提供商。自营多地区数据中心,是 Apnic RIPE Afrinic Arin 认证服务商。拥有丰富的网路资源。 在2021年 6.18 开启了输血大促销,促销区域包括 香港 台湾 日本 莫斯科 等地促销机型为 E3係,参与促销地区有 香港 日本 台湾 莫斯科 等地, 限量50台,售罄为止,先到先得。所有服务器配置 CPU ...

php购物车为你推荐
authorware素材如何用Authorware制作试题96155北京住房公积金电话96155经常没人接?绵阳电信绵阳电信宽带怎么收费的51自学网站推荐一个好一点的自学网站,关于网站建设的。pwpw域名的技巧百度手写百度手写怎么不见了显卡温度多少正常显卡温度多少算正常?iphone越狱后怎么恢复iPhone越狱后怎么恢复?网易公开课怎么下载怎么下载网易公开课里的视频 .......直播加速有没有软件使已经下载好了的视频播放加速,例如30分钟的视频15分钟或者20分钟播放完
海外域名注册 域名备案信息查询 最便宜虚拟主机 warez 优惠码 双11抢红包攻略 服务器cpu性能排行 商家促销 湖南服务器托管 京东商城双十一活动 圣诞促销 双线主机 国外代理服务器软件 稳定免费空间 新世界服务器 免费外链相册 视频服务器是什么 阿里云免费邮箱 汤博乐 贵州电信 更多