PHP更新购物车数量表单部分PHP处理部分
发布时间:2022-07-12 11:21 所属栏目:121 来源:互联网
导读:表单部分: 复制代码 代码如下:www.CuoXIn.com 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 ech
表单部分: 复制代码 代码如下:www.CuoXIn.com <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> PHP 处理部分: 复制代码 代码如下:www.CuoXIn.com <?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; } ?> (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读