嗨,我目前有一些 PHP 代码,它们会将先前从上一页的复选框中选择的时间段放入我的数据库中,但我不确定在执行此操作之前如何将每个时间段存储在一个变量中,以便我可以使用它们来列出预约空档在我的电子邮件功能中
在我尝试将'$key'插入我的电子邮件功能时,它只保留最后选择的值......
我在第一页上的代码如下:
<?php
for ($i=0;$i<=31;$i++){ while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s</td><td>%s</td></tr>\n",
$myrow[0]);
}
echo "<td><input type='checkbox' name='$displayTime2' onclick='KeepCount()'></td>";
echo "<td>$pagetime</td>"; ?>
我目前的代码如下:
<?php
foreach ($_POST as $key=>$value)
{
echo $key; // 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 = "$pemail";
$subject = "Talking Teeth Check Up Booking Confrmation";
$message = "Hello! This e-mail is to confirm your ".$appname." appointment has been
booked for ".$insertdate. " at ".$key." at the ".$pracname." practice";
$from = "talkingteethdentists@talkingteeth.co.uk";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";