もう一度やりましたが、今日は別のテーブルにユーザの現在のIDを挿入する方法を尋ねました。私はユーザーが既に最初のIDを持っていることを意味します。 2番目のテーブルに全く同じIdを挿入したいと思います。1番目のテーブルから2番目のテーブルに同じIDを挿入する方法
<?php
include('connect.php');
$id=$_POST['P_Id'];
$date=$_POST['appdate'];
$time=$_POST['apptime'];
$lname=$_POST['lname'];
$fname=$_POST['fname'];
$contact=$_POST['contact'];
$service=$_POST['service'];
$status = "pending";
$dentist= "Dr. Adrian Romero";
$msg= "Appointment Sucessfully Inserted ";
$update= mysql_query("INSERT INTO appointments (P_Id,LasName,FirstName,contact,appdate,apptime,service,status) values ('$id','$date','$time','$dentist','$fname','$lname','$contact','$service','$status')");
$id=mysql_insert_id();
if($update)
{
echo "<script> alert('Thank you For Requesting an appointment. please wait for the administrator s response after 24 hrs')</script>";
header('Location:Patient.php');
}
else
{
$msge= mysql_error();
$errormsg="Something went wrong, Try again!";
echo "<script type='text/javascript'>alert('$errormsg');</script>";
}
plus。私は実際にmysql_insert_id()の機能を理解していません。あなたは良い一日をありがとう助けてください! :D
何が問題なのですか? –
mysql _ * - 関数は使用しないでください。それらはphp 5.5以降廃止され、PHP 7.0で完全に削除されました。 – Manish
@Adrian Romero mysql_insert_id - 最後のクエリ[http://php.net/manual/en/function.mysql-insert-id.php]で生成されたIDを取得します。 。それはあなたに最後の挿入IDを与えるでしょう。 – Manish