我有一个格式简单的证书。证书需要使用数据库中的值填充并通过电子邮件发送。下面是我做的快速修复。问题是发送的证书不是一个人的,而是那些被查询的。
$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: online@example.com";
$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 个用户是相同的。