Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PhP邮件脚本-错误生成';对于循环脚本';在$message变量中_Php_Email - Fatal编程技术网

PhP邮件脚本-错误生成';对于循环脚本';在$message变量中

PhP邮件脚本-错误生成';对于循环脚本';在$message变量中,php,email,Php,Email,如何添加php for循环脚本以生成电子邮件上的内容(从数据库获取),如下所示 $message = " <html> <head> <title>Your's Weekly Newsletter </title> </head> <body> <p>Hi $to,</p> <p>Here are the highlight of the deals this week:</p>

如何添加php for循环脚本以生成电子邮件上的内容(从数据库获取),如下所示

$message = "
<html>
<head>
<title>Your's Weekly Newsletter </title>
</head>
<body>
<p>Hi $to,</p>
<p>Here are the highlight of the deals this week:</p> 
<br />

<p>    **<?php
   for ($i=0;$i<=$totalCount;$i++) {
   echo \"Deal Description = $HighlightWeeklyNewsletter_array2[$i] <br />\";
   echo \"Deal URL = <a href=\"$HighlightWeeklyNewsletter_array3[$i]\"> More >> $HighlightWeeklyNewsletter_array1[$i] </a> <br />\";
   echo \"Days Left = $HighlightWeeklyNewsletter_array4[$i] <br />\";

   echo \" <hr width=\"auto\" style=\"border: 1px dotted #000000\" size=\"1\"> \";
   }
?>**
</p>

<p> <u>Forward this email</u> to your friends/family and let them know you like this. </p>
<br />
</body>
</html>
";
$message=”
您的每周通讯
你好,我是$to

以下是本周交易的亮点:


****

将此电子邮件转发给您的朋友/家人,并让他们知道您喜欢此邮件


";
不能将php代码嵌入php字符串的内容中。你必须像这样把它分开:

$message = "
<html>
<head>
<title>Your's Weekly Newsletter </title>
</head>
<body>
<p>Hi $to,</p>
<p>Here are the highlight of the deals this week:</p> 
<br />

<p>    **";
for ($i=0;$i<=$totalCount;$i++) {
    $message .= "Deal Description = " . $HighlightWeeklyNewsletter_array2[$i] . "<br />";
    $message .= "Deal URL = <a href=\"" . $HighlightWeeklyNewsletter_array3[$i] . "\"> More >> " . $HighlightWeeklyNewsletter_array1[$i] . "</a> <br />";
    $message .= "Days Left = " . $HighlightWeeklyNewsletter_array4[$i] . "<br />";
    $message .= "<hr width=\"auto\" style=\"border: 1px dotted #000000\" size=\"1\">";
}

$message .= "**
</p>

<p> <u>Forward this email</u> to your friends/family and let them know you like this. </p>
<br />
</body>
</html>
";
$message=”
您的每周通讯
你好,我是$to

以下是本周交易的亮点:


**“; 对于($i=0;$i)