下面的代码在发送email-template.php文件时可以正常工作。我现在想在表格中的电子邮件模板中包含SQL查询的结果,基本上它是一个引号列表。我有一种感觉str_replace
是要走的路,但要成为一个完整的新手,我不知道该怎么做。
<?php
include('connect.php');
include('functions.php');
$sql = "SELECT Quote FROM daily_quote Order By rand() Limit 0,10";
$result = $conn->query($sql);
$to = 'example@example.com';
$subject = "Test";
$htmlContent = file_get_contents("email-template.php");
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: info@example.com' . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Email sending fail.';
endif;
include('footer.php');
答案 0 :(得分:0)
在email-template.php中添加: {place_holder}
以这种方式编辑脚本:
result.GroupBy(x => x.Amount).Where(g => g.Count() > 1).ToList();
并编辑
$sql = "SELECT Quote FROM daily_quote Order By rand() Limit 0,10";
$result = $conn->query($sql);
$template = "<table>";
while($row = $result->fetch_assoc()) {
$template .= "<tr><td>".$row['Quote']."</td></tr>";
$template .= "</table>";