Hi I have created a function whereby the appointment slot times selected using checkboxes on a previous page are added to my database, at the same time the slot times are stored stored so they can be used further down the page in my mail function.
$savedData = array();
foreach ($_POST as $key=>$value)
{ $key = mysql_real_escape_string($key);
echo($key. "<br>"); // show times selected on previous page
mysql_query("INSERT INTO appointment(Patient_ID, Appointment_Date, Appointment_Time
, Practice_ID, Appointment_ID)
VALUES('$patid','$insertdate','$key','$pracid','$apptype')");
//To save the variables for later:
$savedData[] = $key;
}
I now need to use the slot times the user has selected to identify the appointment number which has been autogenerated when they were inserted into my database, the code I have tried to use is as follows:
$insertedapps = mysql_query("SELECT * FROM appointment
WHERE Appointment_Date='".$insertdate."'
AND Appointment_Time='".$key."'");
while($row3 = mysql_fetch_array($insertedapps))
{ $appno = $row3['Appointment_No.'];
}
Mail Function:
$to = "$pemail";
$subject = "Booking Confirmation";
$message = "Hello $pfname
This e-mail is to confirm your $appname appointment has been booked for the below times for $insertdate at the the following time(s) below:
Appointment No: Appointment Time:
$appno[0] $savedData[0]
$appno[1] $savedData[1]
$appno[2] $savedData[2]
$appno[3] $savedData[3]
The above appointment(s) are booked at the $pracname practice
Should you wish to alter this appointment please login via our customer login page or contact us on $pracphone";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
The appointment time's print out fine but I do not get the results for the appointment numbers... can someone point me in the right direction with where I am going wrong?