include_once("../common/common.inc"); include_once("common/preference.inc"); include_once("../common/err.inc"); //データ受け取り・エスケープとか if ($_POST) { foreach ($_POST as $key => $val) { ${$key} = inputs($val); } } $db = db_connect('latin'); session_name('nms'); session_start(); if ($pid) { if ($plus) { if ($plus == '+1') {$num = 1;} else {$num = 10;} stocker('-',$num,$pid,$db); $_SESSION['cart'][$pid] += $num; } elseif ($minus) { if ($minus == '-1') {$num = 1;} else {$num = 10;} stocker('+',$num,$pid,$db); $_SESSION['cart'][$pid] -= $num; } elseif ($delete) { stocker('+',$_SESSION['cart'][$pid],$pid,$db); $num = $_SESSION['cart'][$pid] = 0; } else { stocker('-',$num,$pid,$db); $_SESSION['cart'][$pid] += $num; } } elseif ($clear) { foreach ($_SESSION['cart'] as $key => $val) { stocker('+',$val,$key,$db); } $_SESSION['cart'] = array(); } //在庫の増減 function stocker($fugo,$num,$pid,$db) { $sql = 'UPDATE products SET stock=stock'.$fugo.$num.' WHERE pid=\''.$pid.'\''; $result = mysql_query($sql,$db) or err_msg('DBエラーstocker',$sql.mysql_error()); } ?>