无为清净楼资源网 Design By www.qnjia.com
购物车网页代码,具体内容如下
1.登录界面login.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="/UploadFiles/2021-04-02/jquery-1.11.2.min.js">2.登录处理页面loginchuli.php
<"../DBDA.class.php"); $db = new DBDA(); $uid = $_POST["u"]; $pwd = $_POST["p"]; $sql = "select password from login where username='{$uid}'"; $mm = $db->StrQuery($sql); if($mm==$pwd && $pwd!="") { $UserName = $_POST["uid"]; $_SESSION["uid"]=$uid; echo "OK"; } else { echo "NO"; }3.主页面main.php
<"../DBDA.class.php"); $db = new DBDA(); "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title><br /> <style type="text/css"> .list{ width:100%; height:30px; margin-top:10px; text-align:center; line-height:30px; vertical-align:middle} </style> </head> <body> <div style="width:100%; height:100px; background-color:#6CC"> <h1 style="float:left">大苹果商城</h1> <a style="float:right; margin-top:40px" href="zhuxiao.php">注销</a> </div> <br /> <div style="width:100%; height:600px"> <div id="left" style="width:20%; float:left"> <a href="main.php"><div class="list">浏览商品</div></a> <a href="zhanghu.php"><div class="list">查看账户</div></a> <a href="gouwuche.php"><div class="list">查看购物车</div></a> </div> <div id="right" style="width:80%; float:left"> <"gwc"])) { $agwc = $_SESSION["gwc"]; } $zhonglei = count($agwc); $sum = 0; foreach($agwc as $v) { $sql = "select price from fruit where ids='{$v[0]}'"; $danjia = $db->StrQuery($sql); $sum = $sum +$danjia*$v[1]; } echo "<div>购物车中有:{$zhonglei}种商品,总价格为:{$sum}元.</div>"; "100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>代号</td> <td>水果名称</td> <td>水果价格</td> <td>源产地</td> <td>库存量</td> <td>操作</td> </tr> <"select * from fruit"; $attr = $db->Query($sql); foreach($attr as $v) { echo "<tr><td>{$v[0]}</td> <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td><a href='goumai.php"; } "htmlcode"><"code"]; if(empty($_SESSION["gwc"])) { //第一次点击购买 $attr = array( array($code,1) ); $_SESSION["gwc"] = $attr; } else { //不是第一次点击购买 $attr = $_SESSION["gwc"]; $bs=0; foreach($attr as $k=>$v) { if($v[0]==$code) { $bs=1; $attr[$k][1] = $attr[$k][1]+1; } } //如果没有在数组里面出现 if($bs==0) { $shuzu = array($code,1); $attr[] = $shuzu; } $_SESSION["gwc"]=$attr; } header("location:main.php");5.订单处理页面,计算选取水果的总价,和水果剩余量。dingdan.php
<"../DBDA.class.php"); $db = new DBDA(); $uid = $_SESSION["uid"]; $attr = array(); if(!empty($_SESSION["gwc"])) { $attr = $_SESSION["gwc"]; } //看下两个条件是否都满足 $bs = true; //判断余额是否满足 //根据用户名找余额 $syue = "select account from login where username='{$uid}'"; $yue = $db->StrQuery($syue); //根据购物车数组取总金额 $sum = 0; foreach($attr as $v) { $sql = "select price from fruit where ids='{$v[0]}'"; $danjia = $db->StrQuery($sql); $sum = $sum +$danjia*$v[1]; } if($yue<$sum) { $bs = false; echo "YEBUZU"; exit; } //判断库存是否满足 foreach($attr as $v) { $skucun = "select name,numbers from fruit where ids='{$v[0]}'"; $akucun = $db->Query($skucun); if($akucun[0][1]<$v[1]) { $bs = false; echo "{$akucun[0][0]}库存不足!"; exit; } } //添加订单,减库存,减余额 if($bs) { //减库存 foreach($attr as $v) { $sql = "update fruit set numbers = numbers-{$v[1]} where ids='{$v[0]}'"; $db->Query($sql,0); } //减余额 $jianyue="update login set account=account-{$sum} where username='{$uid}'"; $db->Query($jianyue,0); //添加订单 $dingdanhao = $uid+date("YmdHis"); $t = time(); $sorder = "insert into orders values('{$dingdanhao}','{$uid}','{$t}')"; $db->Query($sorder,0); foreach($attr as $v) { $sxq = "insert into orderdetails values('','{$dingdanhao}','{$v[0]}','{$v[1]}')"; $db->Query($sxq,0); } } echo "OK";6.购物车页面
<"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title><br /> <style type="text/css"> .list{ width:100%; height:30px; margin-top:10px; text-align:center; line-height:30px; vertical-align:middle} </style> <script src="/UploadFiles/2021-04-02/jquery-1.11.2.min.js">7.购物车页面删除处理页面shanchu.php
<"sy"]; $attr = $_SESSION["gwc"]; if($attr[$sy][1]>1) { $attr[$sy][1] = $attr[$sy][1]-1; } else { unset($attr[$sy]); $attr = array_values($attr); } $_SESSION["gwc"]=$attr; header("location:gouwuche.php"); 8.账户余额页面zhanghu.php <"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title><br /> <style type="text/css"> .list{ width:100%; height:30px; margin-top:10px; text-align:center; line-height:30px; vertical-align:middle} </style> </head> <body> <div style="width:100%; height:100px; background-color:#6CC"> <h1 style="float:left">大苹果商城</h1> <a style="float:right; margin-top:40px" href="zhuxiao.php">注销</a> </div> <br /> <div style="width:100%; height:600px"> <div id="left" style="width:20%; float:left"> <a href="main.php"><div class="list">浏览商品</div></a> <a href="zhanghu.php"><div class="list">查看账户</div></a> <a href="gouwuche.php"><div class="list">查看购物车</div></a> </div> <div id="right" style="width:80%; height:150px; float:left"> <"../DBDA.class.php"); $db = new DBDA(); $sql = "select Account from login where UserName='{$uid}'"; $result = $db->strQuery($sql); echo ("您的账户中还剩余".$result); ?> </div> </div> </body> </html>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月13日
2024年11月13日
- 群星《唱给女人的歌》24K德国HD金碟[WAV+CUE]
- 孙燕姿.2011-是时候【美妙音乐】【WAV+CUE】
- 苏芮.2003-回首·时代全经典2CD【华纳】【WAV+CUE】
- 梁咏琪.1996-爱自己【EEI】【WAV+CUE】
- IGN经典逆天骚操作名著——《墙头草修炼手册》
- 突然爆火的“网红游戏”,真的有那么多人玩吗?
- 何老师客串《浪人崛起》了?盘点与明星撞脸的角色!
- 【原神】关于星鹫赤羽对珐芙琴班配队下珐露珊主C的适配度分析
- 【原神】V5.1攻略 | 迪西雅角色简评
- 【原神】大日御舆顶端怎么上去
- 胥拉齐《感谢有你》DTS-WAV
- 罗海英《金牌歌后》【WAV+CUE】
- 林叶《林叶·夜》【WAV/分轨】
- 群星《国语经典名曲01》音乐磁场系列[WAV+CUE][1G]
- 齐豫《滚石24K》24K金碟珍藏版系列[低速原抓WAV+分轨][1G]