gpt4 book ai didi

带变量的 php 邮件

转载 作者:行者123 更新时间:2023-11-29 06:15:39 30 4
gpt4 key购买 nike

我正在尝试设置一个邮件脚本,该脚本将首先从 mysql 运行一个简单的选择,并在消息中使用这些数组变量。然而,所有的变量并没有输出到消息体,只有一行变量。这是我的脚本:

    $sql1 = "SELECT * FROM videos WHERE checked_out = '1'"; 
$result1 = $dbLink->query($sql1);
while($row1 = $result1->fetch_assoc()) {
$name = $row1['name'];
$tape_no = $row1['tape_no'];
$member_name = $row1['member_name'];
$date_out = date("F j, Y", strtotime($row1['date_out']));
}

//email function to administrator
$to = "nouser@mail.com";
$subject = "Daily Video Rental Summary";
$message = "$name $tape_no $date_out $member_name
======================================================================
PLEASE DO NOT REPLY TO THIS MESSAGE, AS THIS MAILBOX IS NOT MONITORED
======================================================================";
$from = "no_replies_please@mail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);

感谢任何人愿意就此分享的任何见解。谢谢,——马特

最佳答案

试试这个:

 $sql1 = "SELECT * FROM videos WHERE checked_out = '1'";
$result1 = $dbLink - > query($sql1);
while ($row1 = $result1 - > fetch_assoc()) {
$name = $row1['name'];
$tape_no = $row1['tape_no'];
$member_name = $row1['member_name'];
$date_out = date("F j, Y", strtotime($row1['date_out']));
//email function to administrator
$to = "nouser@mail.com";
$subject = "Daily Video Rental Summary";
$message = "$name $tape_no $date_out $member_name
======================================================================
PLEASE DO NOT REPLY TO THIS MESSAGE, AS THIS MAILBOX IS NOT MONITORED
======================================================================";
$from = "no_replies_please@mail.com";
$headers = "From:".$from;
mail($to, $subject, $message, $headers);
}

这将每行发送一封邮件。

关于带变量的 php 邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6768141/

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