Home >Backend Development >PHP Tutorial >An example of code to update the shopping cart quantity in PHP

An example of code to update the shopping cart quantity in PHP

PHP中文网
PHP中文网Original
2017-03-13 13:11:161340browse

<?php
/**
* php购物车 处理代码
* Edit bbs.it-home.org
*/
require &#39;config.inc.php&#39;; //配置文件
require &#39;checklogin.php&#39;; //登录检测
$username = $_SESSION[&#39;username&#39;];
$action = $_GET[&#39;action&#39;];
switch ($action) {
case "edit_num":
$arr = $arr = $_POST[&#39;suliang&#39;];
foreach($arr as $key=>$value){
$sqlgx = "update `cartemp` set suliang=&#39;$value&#39; where username=&#39;".$username."&#39; and flag=0 and sp_id=&#39;".$key."&#39;";
mysql_query($sqlgx, $conn);
echo "<script>location.href=&#39;shopcat.php&#39;</script>";
}
break;
case "null":
$null_sql = "delete from `cartemp` where username=&#39;$username&#39; and flag=0 ";
mysql_query($null_sql, $conn);
echo "<script>location.href=&#39;shopcat.php&#39;</script>";
break;
case "del":
$id = $_GET[&#39;id&#39;];
$del_sql = "delete from `cartemp` where id=$id";
mysql_query($del_sql, $conn);
echo "<script>location.href=&#39;shopcat.php&#39;</script>";
break;
}
?>




   





Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn