我在将一个字段从一个表插入另一个字段时遇到问题。我有两个表:会员表和预订表。在这两个表中我都有member_ID我想从成员表中获取member_ID的值并将其插入保留表中。
这是我的代码:
$type=$_POST['serv_name'];
$no=$_POST['reserv_hours'];
$time=$_POST['reserv_time'];
$date=$_POST['reserv_date'];
$ID=$_POST['member_ID'];
$fn=$_SESSION['fn'];
$sql=mysql_query("INSERT INTO reservation (serv_name,reserv_hours,reserv_time,reserv_date,member_ID)
VALUES ('$type','$no','$time','$date',$ID)");
$sql1=mysql_query("INSERT INTO reservation (reserv_ID,serv_name,reserv_hours,reserv_time,reserv_date,member_ID)
(SELECT r.reserv_ID,r.serv_name,r.reserv_hours,r.reserv_time,r.reserv_date,m.member_ID FROM reservation r LEFT JOIN member m ON r.member_ID=m.member_ID)");
$result = ($sql.$sql1);
if($result)
{
header("Location:payment.php");
}
else
{
echo "ERROR!";
header("refresh:5;url=main.php");
}
它正在工作并且确实在我的数据库中注册,但我的预订表中的member_ID仍然为 0。请帮助。先感谢您。