当前位置:Gxlcms > PHP教程 > php实现购物车数量更新的代码一例

php实现购物车数量更新的代码一例

时间:2021-07-01 10:21:17 帮助过:12人阅读

<?php
/**
* php购物车 处理代码
* Edit bbs.it-home.org
*/
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;
}
?>

人气教程排行