|
|
|
ช่วยด้วยครับ ผมจะตรวจสอบเงื่อนไขเวลากด checkbox ทำไงช่วยบอกที |
|
|
|
|
|
|
|
คุณน่าจะทำตั้งแต่ขั้นตอนการเก็บลงตะกร้า session ครับ สะดวกกว่า
|
|
|
|
|
Date :
2012-03-14 17:45:16 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนี้หรอครับ
Code (PHP)
<? $grantotal=0;
$notr=0;
if (isset ($_SESSION["ses_basket_items"])){
$ses_basket_items= $_SESSION["ses_basket_items"];
$ses_basket_price=$_SESSION["ses_basket_price"];
$ses_basket_amount=$_SESSION["ses_basket_amount"];
$ses_basket_id=$_SESSION["ses_basket_id"];
for ( $basket_counter=0; $basket_counter < $ses_basket_items; $basket_counter++ ){
$sespro_price = $ses_basket_price[$basket_counter];
$quantity = $ses_basket_amount[$basket_counter];
$sespro_id = $ses_basket_id[$basket_counter];
$sumprice=$sespro_price*$quantity;
if($quantity>0){
$grantotal=$grantotal+$sumprice;
++$notr;
//หาจำนวนใน Stock
$sql_stock="select pro_total from products where no=".$sespro_id;
$query=mysql_query($sql_stock);
$Rs_stock=mysql_fetch_array($query);
$db_stock=$Rs_stock["pro_total"];
?>
หรือแบบนี้คัฟ
Code (PHP)
if (isset ($_SESSION["ses_basket_items"])){
$name=$_POST['name'];
$addr=$_POST['addr'];
$valid_uname=$rs["cus_id"];
//รหัสรายการสั่งซื้อ
$sql_max="select MAX(or_id) as neworder from orders";
$maxrs=mysql_db_query($db,$sql_max);
$result_max = mysql_fetch_array($maxrs);
$neworder=$result_max["neworder"]+1;
$_SESSION['currorderid']=$neworder;//ใบสั่งซื้อปัจจุบัน
//tb-order
$sql_insert="insert into orders (or_id,cus_id,cus_full,cus_add,or_date)
values ($neworder,'$memid','$name','$addr',now())";
mysql_query($sql_insert) or die("Error Ins Table orders");
//order_item
$ses_basket_items= $_SESSION["ses_basket_items"];
$ses_basket_price=$_SESSION["ses_basket_price"];
$ses_basket_amount=$_SESSION["ses_basket_amount"];
$ses_basket_id=$_SESSION["ses_basket_id"];
for ( $basket_counter=0; $basket_counter < $ses_basket_items; $basket_counter++ ){
$sespro_price = $ses_basket_price[$basket_counter];
$quantity = $ses_basket_amount[$basket_counter];
$sespro_id = $ses_basket_id[$basket_counter];
$sumprice=$sespro_price*$quantity;
if($quantity>0){
$sql_insertItem="insert into order_item (or_id,pro_id,item_price,price_total)
values ($neworder,$sespro_id,$sumprice,$quantity)";
mysql_query($sql_insertItem) or die("Error Ins order_item");
}
}
session_unregister("ses_basket_items");
session_unregister("ses_basket_price");
session_unregister("ses_basket_amount");
session_unregister("ses_basket_id");
}
?>
|
ประวัติการแก้ไข 2012-03-14 20:08:44 2012-03-14 20:09:48
|
|
|
|
Date :
2012-03-14 20:06:31 |
By :
KwanG_Sone |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|