Though there is nothing wrong with that, an easyer method is to use
mysql_insert_id()
http://ca3.php.net/manual/en/function.mysql-insert-id.php
# use this statement to enter the patient data
$sql_1= INSERT INTO patients (f_name, l_name, phone_num) VALUES (‘$f_name’, ‘$l_name’, ‘$phone_num’);
$res_1 = mysql_query($sql, $conn) or die(mysql_error());
#get the patient id based on the last insert
$id = mysql_insert_id($conn);
#enter the data in the appointment table
$sql_3 = INSERT INTO appointment (appt_date, appt_time, id) VALUES (‘$appt_date’, ‘$appt_time’, ‘$id’)