嗨,我创建了一个功能,将使用前一页上的复选框选择的预约时段添加到我的数据库中,同时存储时段,以便可以在我的邮件功能页面的下方进一步使用它们。
$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;
}
我现在需要使用用户选择的时间段来识别插入我的数据库时自动生成的约会号码,我尝试使用的代码如下:
$insertedapps = mysql_query("SELECT * FROM appointment
WHERE Appointment_Date='".$insertdate."'
AND Appointment_Time='".$key."'");
while($row3 = mysql_fetch_array($insertedapps))
{ $appno = $row3['Appointment_No.'];
}
邮件功能:
$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 = "xxxxx@xxxx.xxxx";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
约会时间打印得很好,但我没有得到约会号码的结果……有人能指出我哪里出错了吗?