gpt4 book ai didi

php - 电子邮件中的动态表

转载 作者:行者123 更新时间:2023-11-29 14:26:23 24 4
gpt4 key购买 nike

在过去的几个小时里,我一直在尝试在电子邮件中创建一个动态表..但我没有成功,我尝试在主体变量中和外部创建表并在其中回显它,但我没有成功我已经把我的代码放在下面了..任何帮助都会非常感谢..我想做的就是创建一个包含一些mysql数据的表,然后将其发送给一些客户..这只是我所做的事情的一个总结尝试完成

$link = mysql_connect('localhost', 'root', '');
mysql_select_db('netbookdb');
$sql="SELECT * FROM rep_log WHERE s_date = '2012-05-31'";
$result=mysql_query($sql, $link);


$date=date('dmy');
require("../PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp"; // specify main and backup server

$mail->From = "support@.vic.edu.au";
$mail->FromName = "Ict Devices";
$mail->AddAddress("email@h.vic.edu.au", "Matthew");


$mail->Subject = "Damage Log Report";

$mail->IsHTML(true);
$var='xlsx';
$date=date('dmy.');

$mail->Body = " while($rows=mysql_fetch_array($result)){
$cases=$rows['cases'];
$hg=$rows['hg'];
$surname=$rows['surname'];
$firstname=$rows['firstname'];
$claim=$rows['claim'];
$damage=$rows['damage'];
$cost=$rows['cost'];

}";
$mail->AltBody="Please Use a Html Compaible Email Veiwer";



if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
echo "Letter is sent";
}

最佳答案

我使用我创建的和平代码来获取脚本来创建动态表,然后将其回显到电子邮件正文中,这只是一个基本表,但可以进行改进

$link = mysql_connect('localhost', 'root', '');
mysql_select_db('Your Dataabse name');
$sql="SELECT * FROM rep_log WHERE claim='Insurance' AND s_date = '2012-05-31'";
$result=mysql_query($sql, $link);

$table= "<table width='100%' border='3' cellspacing='0' cellpadding='0'>";
$table .="<th>Cases</th>";
$table .="<th>HG</th>";
$table .="<th>Surname</th>";
$table .="<th>FristName</th>";
$table .="<th>Claim</th>";
$table .="<th>Damage</th>";
$table .="<th>Cost</th>";

while($rows=mysql_fetch_array($result)){
$cases=$rows['cases'];
$hg=$rows['hg'];
$surname=$rows['surname'];
$firstname=$rows['firstname'];
$claim=$rows['claim'];
$damage=$rows['damage'];
$cost=$rows['cost'];
$table .="<tr>";
$table .="<td>$cases</td>";
$table .="<td>$hg</td>";
$table .="<td>$surname</td>";
$table .="<td>$firstname</td>";
$table .="<td>$claim</td>";
$table .="<td>$damage</td>";
$table .="<td>$cost</td>";
$table .="</tr>";


}
$table .="</table>";

$date=date('dmy');
require("../PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp"; // specify main and backup server

$mail->From = "support@ac.vic.edu.au";
$mail->FromName = "Ict Devices";
$mail->AddAddress("gs@hum.vic.edu.au", "Matthew");


$mail->Subject = "Damage Log Report";

$mail->IsHTML(true);
$var='xlsx';
$date=date('dmy.');

$mail->Body = "$table;";
$mail->AltBody="Please Use a Html Compaible Email Veiwer";



if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
echo "Letter is sent";
}

关于php - 电子邮件中的动态表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10890390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com