|
|
|
[PHP] เรื่องการสั่ง order สินค้าแล้วบันทึกลง Data base ครับ |
|
|
|
|
|
|
|
ไม่ทราบว่าผมพลาดตรงไหนเหรอครับ ?
Quote:DBชื่อ shopdb
Tableชื่อ tb_order
มีฟิวด์
- id (เป็น auto)
- refid
- pNum
- pPrice
- id_cus
- date
- pld
- sent_rate
- paystatus
- statusnow
- address2
Code (PHP)
$address_new = "$_POST[address] ถนน $_POST[road] ตำบล/แขวง : $_POST[district] อำเภอ/แขวง : $_POST[city] จ.$_POST[province] $_POST[zipcode] ประเทศ : $_POST[country]";
$randnum = rand(111111,999999);
$sql_numcode="select * from tb_order";
$db_queryr=mysql_db_query($db,$sql_numcode);
$result_numcode=mysql_fetch_array($db_queryr);
$num_rows_code=mysql_num_rows($db_queryr);
$run_number = $num_rows_code+1;
$rand_num=sprintf("%05d",$run_number);
$userCus = $_GET[user];
$passCus = $_GET[pass];
$sent_rate = $_GET[sr];
$today = date("d-m-Y");
$sql="select * from member where usermem='$usermem' ";
$result=mysql_db_query($db,$sql);
$rs=mysql_fetch_array($result);
$dateorder = date("$e_date");
$dateime1 = $dateorder;
$date = explode('/', $dateime1);
$newdate = implode('-', array($date[2], $date[1], $date[0]));
for ($n=0;$n<count($sess_idproduct);$n++) {
$sql1= insert("refid,pNum,pPrice,id_cus,date,pld,sent_rate,paystatus,statusnow,address2"," '$sess_idproduct[$n]','$randnum','$sess_num[$n]','$sess_price[$n]','$newdate','$usermem' ","tb_order");
mysql_db_query($db,$sql1);
$sql_data = "update products set amount = amount-$sess_num[$n] where productscode = '$sess_idproduct[$n]'";
mysql_query($sql_data);
$sql_update_address = "update tb_order set address2 = '$address_new' where refid = '$randnum'";
mysql_query($sql_update_address);
$sql_stats = "update products set stats = stats+1 where productscode = '$sess_idproduct[$n]'";
mysql_query($sql_stats);
}
** มันขึ้นเตือนที่บันทัดนี้ครับ **
Code (PHP)
$sql1= insert("refid,pNum,pPrice,id_cus,date,pld,sent_rate,paystatus,statusnow,address2"," '$sess_idproduct[$n]','$randnum','$sess_num[$n]','$sess_price[$n]','$newdate','$usermem' ","tb_order");
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2012-09-01 20:26:00 2012-09-01 20:27:17
|
|
|
|
|
Date :
2012-09-01 20:24:47 |
By :
talememorize |
View :
1207 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใน function insert() ให้ใช้ mysql_query($sql) or die(mysql_error())
|
|
|
|
|
Date :
2012-09-01 21:08:54 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|