|
 |
|
พี่นู๋อยากทราบเกี่ยวกับคำสั่ง insert into นู๋ไม่ทราบว่าทำไมข้อมูลถึงไม่ลงในฐานข้อมูล |
|
 |
|
|
 |
 |
|
พี่นู๋เขียนคำสั่งแบบข้างล่างนี้แต่ว่าทำมัยถึงไม่ลงในฐานข้อมูลเลย ไม่ว่าจะเป็น tblOrders หรือว่าจะเป็น tblOrderItems อยากให้พี่ช่วยแนะนำวิธีเขียนหน่อย อธิบายให้ด้วยก้อได้นู๋ไม่ค่อยชำนาญ
Code (PHP)
<?php require_once("../includes/template.php") ; require_once("../includes/function.php") ;
require_once("includes/shopping_function.php");
show_header("บันทึกรายการสั่งซื้อ") ; show_menu() ; check_authen("member") ;
if ( !empty( $_POST["btnNext"] ) ) {
if ( empty($_POST["txtName"]) || empty($_POST["txtSurname"]) || empty($_POST["txtAddress"]) || empty($_POST["txtDistrict"]) || $_POST["selProvince"] == "0" || empty($_POST["txtZipcode"]) ) {
process_message( "กรอกข้อมูลไม่ครบ", "shopping_process2.php" ) ;
} else {
$dblink = connect_db() ;
$now = date( "y-m-d h:i:s" ) ;
$ship_name = $_POST["txtName"] . " " . $_POST["txtSurname"] ;
$ship_address = $_POST["txtAddress"] . " เขต/อำเภอ " . $_POST["txtDistrict"] . " จังหวัด " . $_POST["selProvince"]." รหัสไปรษณีย์ " . $_POST["txtZipcode"] ;
$insert = "INSERT INTO tblOrders (mUserName, oDateTime, oShipName, oShipAddress, oShipping, oStatus, oBill) VALUES ('" . $_SESSION["ssMember"] . "', '" . $now . "', '" . $ship_name . "', '" . $ship_address . "', '" . $_POST["hShip"] . "', 1, '" . $_POST["rdoBill"] . "') " ;
$resultSql = mysqli_query( $dblink, $insert ) ;
$affected = mysqli_affected_rows( $dblink ) ;
$orderid = mysqli_insert_id( $dblink ) ;
if ( $affected == 1 ) {
$arrItems = explode( "|", $_SESSION["cart"] ) ;
$arrQuality = explode( "|", $_SESSION["quality"] ) ;
for ($i=0; $i < count($arrItems); $i++) {
$insertItems = "INSERT INTO tblOrderItems (orderID, code, oiQuantity) VALUES ( '" . $orderid."', '" . $arrItems[$i] . "', " . $arrQuality[$i] . ") " ;
}
$resultSql = mysqli_query($dblink,$insertItems);
}
unset( $_SESSION["cart"] ) ;
unset( $_SESSION["quality"] ) ;
unset( $_SESSION["Shipping"] ) ;
$msg = "บันทึกรายการสั่งซื้อเรียบร้อยแล้ว" ;
process_message( $msg, "print_orderReport.php?oid=".$orderid ) ;
}
mysqli_close( $dblink ) ;
}
show_footer(); ?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2010-09-29 20:05:18 |
By :
hatinee |
View :
870 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบไปก่อนหน้านี้แล้วน่ะครับ 
|
 |
 |
 |
 |
Date :
2010-09-29 22:56:48 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|