首页  >  文章  >  后端开发  >  PHP更新购物车数量(表单部分/PHP处理部分)_PHP教程

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

WBOY
WBOY原创
2016-07-21 15:10:35743浏览

表单部分

复制代码 代码如下:






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;
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327053.htmlTechArticle表单部分 : 复制代码 代码如下: 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...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn