|
 |
|
ช่วยดูคำสั่งSQLในการบันทึกข้อมูลการสั่งซื้อสินค้าให้ผมที ครับ มันบันทึกแต่รายการแรกแต่รายการที่ 2 ไม่บันทึกอ่าครับ |
|
 |
|
|
 |
 |
|
if($_POST["action"]=="add")
{
// OrderID
$strResultOrderID=select("orderid","where 1");
$strOrderID="ORDER-".substr("000000000$strResultOrderID[OrderID]", -6);
//MemberID
$strMemberID=select("member","where 1 and Email='".$_SESSION["strEmail"]."'");
// Insert Order
$sql = "insert into cusorder (OrderNo,MemberID,Total,Date,status) Values ('$strOrderID','$strMemberID[MemberID]','$_POST[txtTotal]','".date("Y-m-d")."','1')";
$dbquery = mysql_query($sql);
// Insert Detail
for($i=0;$i<=count($_SESSION["strProductID"]);$i++)
{
$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"]["$i"]."' ");
if($result)
{
$Proid=$_SESSION["strProductID"]["$i"];
$Quanlity=$_SESSION["strQuanlity"]["$i"];
$sql = "update product set Stock=Stock-$Quanlity where ProductID='$Proid'";
$dbquery = mysql_query($sql);
$sql = "insert into order_detail (OrderNo,ProductID,Quanlity) Values ('$strOrderID','".$_SESSION["strProductID"]["$i"]."','".$_SESSION["strQuanlity"]["$i"]."')";
$dbquery = mysql_query($sql);
}
}
// Update Order ตัวต่อไปให้เป็น 1
update("orderid","OrderID=OrderID+1","where 1");
$_SESSION["strP"]="";
$_SESSION["strProductID"]="";
$_SESSION["strQuanlity"]="";
session_write_close();
//============ กระโดดไปหน้า ordercomplete.php
header("location:ordercomplete.php?OrderID=$strOrderID");
}
โค๊ดข้างต้นอ่ะครับมันบันทึกสินค้าได้แค่รายการเดียวเองอ่าครับ คือว่ามันบันทึกลงฐานข้อมูลรายการสินค้าอันแรกอ่าครับตั้งแต่รายการที่ 2 มันไม่บันทึกให้
Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP, Report Others

|
|
 |
 |
 |
 |
Date :
2010-11-02 15:17:48 |
By :
494244091 |
View :
1497 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อิอิ ขอบคุณสำหรับผู้ที่กำลังช่วยนะครับพอดีแก้ไปแก้มาได้แหละครับ
|
 |
 |
 |
 |
Date :
2010-11-02 15:45:08 |
By :
494244091 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|