源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

PHP更新购物车数量(表单部分/PHP处理部分)

  • 时间:2021-12-02 13:52 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:PHP更新购物车数量(表单部分/PHP处理部分)
[b]表单部分[/b]:
[u]复制代码[/u] 代码如下:
<form action="?action=edit_num" method="post" name="car<?php $c_rs['id'];?>" id="car<?php $c_rs['id'];?>"> <input name="suliang[<?php echo $c_rs['sp_id'];?>]" type="text" id="suliang[<?php echo $c_rs['sp_id'];?>]" value="<?php echo $c_rs['suliang'];?>"/> <input type="submit" name="button" id="button" value="更新购物车" /> </form>
[b]PHP 处理部分[/b]:
[u]复制代码[/u] 代码如下:
<?php require 'config.inc.php'; require 'checklogin.php'; $username = $_SESSION['username']; $action = $_GET['action']; switch ($action) { case "edit_num": $arr = $arr = $_POST['suliang']; foreach($arr as $key=>$value){ $sqlgx = "update `cartemp` set suliang='$value' where username='".$username."' and flag=0 and sp_id='".$key."'"; mysql_query($sqlgx, $conn); echo "<script>location.href='shopcat.php'</script>"; } break; case "null": $null_sql = "delete from `cartemp` where username='$username' and flag=0 "; mysql_query($null_sql, $conn); echo "<script>location.href='shopcat.php'</script>"; break; case "del": $id = $_GET['id']; $del_sql = "delete from `cartemp` where id=$id"; mysql_query($del_sql, $conn); echo "<script>location.href='shopcat.php'</script>"; break; } ?>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部