|
 |
|
ช่วยดูให้หน่อยครับทำไมบันทึกไม่ได้ครับ ผมบันทึกพร้อมกัน 3 ตาราง |
|
 |
|
|
 |
 |
|
Code (PHP)
$strMode = $_POST["tMode"];
$objConnect = mysql_connect("localhost","root","123") or die("Error Connect to Database");
$objDB = mysql_select_db("db_transfer");
if($strMode == "ADD"){
----------------------------------------------------------
$strSQL = "INSERT INTO tbl_student ";
$strSQL .="(std_id,id_add,name,class,branch,school,add_date) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["tstd_id"]."','".$_POST["tid_add"]."','".$_POST["tname"]."','".$_POST["tclass"]."' ";
$strSQL .=",'".$_POST["tbranch"]."','".$_POST["tschool"]."','".$_POST["tdate_time"]."') ";
$objQuery = mysql_query($strSQL)or die ("Error Query [".$strSQL."]");
------------------------------------------------------------
$strSQL1 = "INSERT INTO tbl_vocational ";
$strSQL1 .="(std_id,sub_vid,sub_name,cradit,Grade_vocational) ";
$strSQL1 .="VALUES ";
$strSQL1 .="('".$_POST["tstd_id"]."','".$_POST["tsub_vid"]."','".$_POST["tsub_name_v"]."'";
$strSQL1 .=",'".$_POST["tcradit_v"]."','".$_POST["tGrade_vocational"]."') ";
$objQuery = mysql_query($strSQL1)or die ("Error Query [".$strSQL1."]");
------------------------------------------------------------
$strSQL2 = "INSERT INTO tbl_bachelor ";
$strSQL2 .="(std_id,sub_bid,sub_name,cradit,Grade_bachelor) ";
$strSQL2 .="VALUES ";
$strSQL2 .="('".$_POST["tstd_id"]."','".$_POST["tsub_bid"]."','".$_POST["tsub_name_b"]."'";
$strSQL2 .=",'".$_POST["tcradit_b"]."','".$_POST["tGrade_bachelor"]."') ";
$objQuery = mysql_query($strSQL2)or die ("Error Query [".$strSQL2."]");
}
Tag : PHP, MySQL, Ajax

|
ประวัติการแก้ไข 2011-11-10 18:21:54 2011-11-10 18:23:30 2011-11-10 18:24:04
|
 |
 |
 |
 |
Date :
2011-11-10 18:20:36 |
By :
Testprogram |
View :
906 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อย่างแรก มันมีค่าถูกส่งมาหรือ
อย่างสอง ตรงนี้ลองเพิ่ม $objQuery = mysql_query($strSQL) or die (mysql_error());
อย่างสาม ก็ลองดูชื่องของตาราง ฟิลด์ว่าตรงไหม
อย่างสี่ ก็การเชื่องต่อฐานข้อมูล ลองเช็คดู
สุดท้าย ตรงนี้น่ะ $strSQL .="(std_id,id_add,name,class,branch,school,add_date) "; ด็อท มันอยู่ก่อน = หรือว่ามันต้องอยู่หลัง = ลองเช็คตามตัวอย่างดูนะ เพราะผมก็ไม่ได้ใช้วิธีนี้ซะด้วยสิ รู้สึกว่ามันเปลืองบรรทัดน่ะ
|
 |
 |
 |
 |
Date :
2011-11-10 21:53:40 |
By :
ozma |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|