|
 |
|
การ เพิ่มข้อมูล 2 table ใน ฟอมเดียว ช่วยดูทีค่ะ เพิ่มไม่ลง |
|
 |
|
|
 |
 |
|
ช่วยดูทีค่ะ ว่าผิดตรงไหน
คือทำแล้วมัน ใส่ข้อมูลเพิ่มไปแค่ในส่วนของ tb_admin แต่ใน tb_account ไม่เพิ่มอะค่ะ
ผิดตรงไหนหรอคะ ทำนานแล้วไม่ได้สักที รบกวนทีค่ะ
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("project");
$strSQL = "INSERT INTO tb_account ";
$strSQL .="(userID,username,password,email,prefix,thaifirstname,thailastname,nationality,race,gender,address,city,province,postcode,telephone,mobile,fax,status,SID,active) ";
$trSQL .="VALUES ";
$strSQL .="('".$_POST["txtuserID"]."','".$_POST["txtusername"]."','".$_POST["txtpassword"]."' ";
$strSQL .=",'".$_POST["txtemail"]."','".$_POST["txtprefix"]."','".$_POST["txtthaifirstname"]."' ";
$strSQL .=",'".$_POST["txtthailastname"]."','".$_POST["txtnationality"]."','".$_POST["txtrace"]."' ";
$strSQL .=",'".$_POST["txtbirth"]."','".$_POST["txtgender"]."','".$_POST["txtaddress"]."' ";
$strSQL .=",'".$_POST["txtcity"]."','".$_POST["txtprovince"]."','".$_POST["txtpostcode"]."' ";
$strSQL .=",'".$_POST["txttelephone"]."','".$_POST["txtmobile"]."','".$_POST["txtfax"]."' ";
$strSQL .=",'".$_POST["ddlstatus"]."','".$_POST["txtSID"]."','".$_POST["ddlactive"]."') ";
$objQuery = mysql_query($strSQL);
$strSQL = "INSERT INTO tb_admin ";
$strSQL .="(adposition,addepartment,userID) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtadposition"]."','".$_POST["txtaddepartment"]."','".$_POST["txtuserID"]."') ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "เพิ่มข้อมูลเรียบร้อย.";
}
else
{
echo "ไม่สามารถเพิ่มข้อมูลได้ [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-05-04 19:36:34 |
By :
kutjung |
View :
1064 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$trSQL > $strSQL
|
 |
 |
 |
 |
Date :
2012-05-04 20:19:05 |
By :
ManGal49 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ยังเหมือนเดิมอะค่ะ เข้าใน table admin ไม่เข้า table account
มีใครพอรู้ไหมคะผิดตรงไหน
|
 |
 |
 |
 |
Date :
2012-05-04 21:31:37 |
By :
kutjung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$strSQL .="(userID,username,password,email,prefix,thaifirstname,thailastname,nationality,race,gender,address,city,province,postcode,telephone,mobile,fax,status,SID,active) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtuserID"]."','".$_POST["txtusername"]."','".$_POST["txtpassword"]."' ";
$strSQL .=",'".$_POST["txtemail"]."','".$_POST["txtprefix"]."','".$_POST["txtthaifirstname"]."' ";
$strSQL .=",'".$_POST["txtthailastname"]."','".$_POST["txtnationality"]."','".$_POST["txtrace"]."' ";
$strSQL .=",'".$_POST["txtbirth"]."','".$_POST["txtgender"]."','".$_POST["txtaddress"]."' ";
$strSQL .=",'".$_POST["txtcity"]."','".$_POST["txtprovince"]."','".$_POST["txtpostcode"]."' ";
$strSQL .=",'".$_POST["txttelephone"]."','".$_POST["txtmobile"]."','".$_POST["txtfax"]."' ";
$strSQL .=",'".$_POST["ddlstatus"]."','".$_POST["txtSID"]."','".$_POST["ddlactive"]."') ";
echo $strSQL;exit;
แล้วดูครับว่าถูกหรือป่าวค่าที่ส่งมา
แล้วมีฟ้องเออเร่ออะไรมั้ย
|
 |
 |
 |
 |
Date :
2012-05-05 05:49:35 |
By :
ManGal49 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$strSQL .="(userID,username,password,email,prefix,thaifirstname,thailastname,nationality,race,gender,address,city,province,postcode,telephone,mobile,fax,status,SID,active) ";
$trSQL .="VALUES ";
$strSQL .="('".$_POST["txtuserID"]."','".$_POST["txtusername"]."','".$_POST["txtpassword"]."' ";
$strSQL .=",'".$_POST["txtemail"]."','".$_POST["txtprefix"]."','".$_POST["txtthaifirstname"]."' ";
$strSQL .=",'".$_POST["txtthailastname"]."','".$_POST["txtnationality"]."','".$_POST["txtrace"]."' ";
$strSQL .=",'".$_POST["txtbirth"]."','".$_POST["txtgender"]."','".$_POST["txtaddress"]."' ";
$strSQL .=",'".$_POST["txtcity"]."','".$_POST["txtprovince"]."','".$_POST["txtpostcode"]."' ";
$strSQL .=",'".$_POST["txttelephone"]."','".$_POST["txtmobile"]."','".$_POST["txtfax"]."' ";
$strSQL .=",'".$_POST["ddlstatus"]."','".$_POST["txtSID"]."','".$_POST["ddlactive"]."') ";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$strSQL = "INSERT INTO tb_admin ";
$strSQL .="(adposition,addepartment,userID) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtadposition"]."','".$_POST["txtaddepartment"]."','".$_POST["txtuserID"]."') ";
$objQuery = mysql_query($strSQL) or die(mysql_error());
if($objQuery)
โดยทั่วไปเค้าไม่ต้องกรอกกันหรอกนะ user id นะ
ใส่นี่เข้าไปจะได้เห็นว่า ไม่ได้เพราะอะไร
|
 |
 |
 |
 |
Date :
2012-05-05 06:11:22 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ละค่ะ ขอบคุณทั้งสองท่านมากๆ เห็นข้อผิดพลาดชัดเจนเลย
|
 |
 |
 |
 |
Date :
2012-05-05 10:07:51 |
By :
kutjung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|