我有一個格式簡單的證書。證書需要填入數據庫中的值並通過電子郵件發送。下面是我做的快速修復。問題是發送的證書不是一個人而是那些被查詢的人。電子郵件生成的HTML與動態值使用PHP
$query ="SELECT r.email, r.LastName, r.OpNo,
r.QuizNo From tbl_cert where Pass =1 AND Printed is null;
$result=mysql_query($query);
while(($row= mysql_fetch_array($result))){
$subject = "CPD Certificate";
$email = $row['email'];
$LastName = $row['LastName'];
$OpNo = $row['OpNo'];
$TestNo = $row['QuizNo'];
$headers = "From: [email protected]";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;
charset=iso-8859-1' . "\r\n";
$mail_body ='<html>...Here its were my my
html comes with values from table...</html>';
if (mail($to, $subject, $mail_body, $headers)){
$query = "UPDATE `tbl_cert` SET Printed = 1
WHERE CertificateNo = " . $CertificateNo;
$certresult=mysql_query($query);
if ($certresult) {
header('Location:tsCertlist.php');
}
問題是如何讓$ mail_body在while循環中同時具有html和php。我生成的表格或證書對於已通過且未打印證書的4位用戶而言是相同的。
'$ query'錯誤 – Sahal