php - 为什么 mysql 数据只打印电子邮件正文中的最后一行?

标签 php mysql pdo

我收到一封带有标题和最后一行的电子邮件。为什么不是所有行?

这是我的完整代码:

$email_from = 'info@email.com';
    $email_to = $row['email'];
    $email_subject = "The " . $row['event'] . " Registration";

    $email_message .= "Dear " . $row['lname'] . " " . $row['fname'] . "\n" ;
    $email_message .= "This is a notice that an invoice for your order has been generated on " . $row['reg_date'] . "\n" ;
    $email_message .= "Your payment method is: " . $row['payment'] . "\n" ;
    $email_message .= "Invoice: " . $row['id'] . "\n" ;
    $email_message .= "Status: Unpaid \n" ;
    $email_message .= "<strong>Invoice Items</strong> \n" ;
    $email_message .= "Event: " . $row['event'] . "\n" ;
    $email_message .= "<hr> \n" ;
    $email_message .= "<hr> \n" ;
    $email_message .= "Here is your Invoice id: ".$row['ref']. "\n" ;

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  

我想这样发邮件

Dear Dasgupta Arnab
This is a notice that an invoice for your order has been generated on: date
Your payment method is: whatever
Invoice: 123456
Status: Unpaid 
Invoice Items 
Event: event name
Here is your Invoice: refid

但我在电子邮件中只收到这样的邮件

Here is your Invoice: refid

最佳答案

试试这个:

    $email_from = 'info@email.com';
$email_to = $row['email'];
$email_subject = "The " . $row['event'] . " Registration";
$email_message="";
$email_message .= "Dear " . $row['lname'] . " " . $row['fname'] . "\n" ;
$email_message .= "This is a notice that an invoice for your order has been generated on " . $row['reg_date'] . "\n" ;
$email_message .= "Your payment method is: " . $row['payment'] . "\n" ;
$email_message .= "Invoice: " . $row['id'] . "\n" ;
$email_message .= "Status: Unpaid \n" ;
$email_message .= "<strong>Invoice Items</strong> \n" ;
$email_message .= "Event: " . $row['event'] . "\n" ;
$email_message .= "<hr> \n" ;
$email_message .= "<hr> \n" ;
$email_message .= "Here is your Invoice id: ".$row['ref']. "\n" ;
// create email headers
$headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 

关于php - 为什么 mysql 数据只打印电子邮件正文中的最后一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50592900/

相关文章:

php - 日期/时间转换为自 php 以来的时间

php - 如何读取用PHP上传的文件的标题?

javascript - 将 Node.js GET/POST 请求更改为 Ajax

php - Laravel:带有 INSERT(外键)的 SQL LEFT JOIN

php - PDO 获取未返回所有行

php - WHERE DATE_FORMAT = DATE_FORMAT 不准确

javascript - 意外的 PHP/jQuery/JSON 交互差异

php - 显示相关内容的链接

Mysql:无法启动服务器 debian wheezy

动态绑定(bind)问号的PHP函数/过程