我需要你的帮助来解决我的问题.. 首先我在mysql dbase中有2个表..这里是结构:
doctor1:
--------
no_que autoincrement pk,
doctor_name,
id_patient,
date,
time
status_que:
----------
id_patient,
doctor_name,
no_que fk,
date,
time
我想将数据插入doctor1,数据在status_que中也是相同的。
$idp=$_POST['id_patient'];
$dt=$_POST['date'];
$tm=$_POST['time'];
$dn=$_POST['doctor_name'];
$query = "INSERT INTO doctor1 (doctor_name, id_patient, date, time)
values ('$dn', '$idp', '$dt', '$tm')";
$result = @mysql_query($query) or die("REPORT Failed to save data.");
$last_insert_no_que = mysql_insert_id();
@query2 = "INSERT INTO status_queue (id_patient, doctor_name, no_que, date, time)
values ('$idp', '$dn', '$last_insert_no_que', '$dt', '$tm')";
$result = @mysql_query($query2) or die("REPORT Failed to save data.");
但该代码不起作用
答案 0 :(得分:0)
它有效!我只需要删除“@”操作符.. :)〜你是
所以这是我的代码:
$idp=$_POST['id_patient'];
$dt=$_POST['date'];
$tm=$_POST['time'];
$dn=$_POST['doctor_name'];
$query = "INSERT INTO doctor1 (doctor_name, id_patient, date, time)
values ('$dn', '$idp', '$dt', '$tm')";
$result = mysql_query($query) or die(mysql_error());
$last_insert_no_que = mysql_insert_id();
$query2 = "INSERT INTO status_queue (id_patient, doctor_name, no_que, date, time)
values ('$idp', '$dn', '$last_insert_no_que', '$dt', '$tm')";
$result = mysql_query($query2) or die(mysql_error());
>