 |
ช่วยดูโค๊ดให้หน่อยนะครับ คือต้องเพิ่มข้อมูล 2 ตารางพร้อมกันโดยอ้าง FK |
|
 |
|
|
 |
 |
|
คือต้องเพิ่มข้อมูล 2 ตารางพร้อมกัน โดยฟิว userID ของตาราง student อ้างจากฟิว userID ของตาราง user
student
-stID PK
-name
-suname
-userID FK auto increment
user
-userID PK auto increment
-username
-password
-grop_user
Code (PHP)
mysql_query("lnsert into student(stID,name,suname,userID) values('$stID','$name','$suname','$userID')")or die(mysql_error());
mysql_query("lnsert into user(userID,username,password,grop_user) values('$userID','$username','$password','$grop_user')")or die(mysql_error());
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2013-01-31 12:45:18 |
By :
jaruwit |
View :
983 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สลับนิดหน่อยครับ
student
-stID PK
-name
-suname
-userID FK auto increment อันนี้ไม่ต้องมี
Code (PHP)
mysql_query("lnsert into user(userID,username,password,grop_user) values('','$username','$password','$grop_user')")or die(mysql_error());
$userID = mysql_insert_id();
mysql_query("lnsert into student(stID,name,suname,userID) values('$stID','$name','$suname','$userID')")or die(mysql_error());
|
 |
 |
 |
 |
Date :
2013-01-31 12:52:50 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|