Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.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 群发电子邮件错误,根据找到的记录数重复内容_Php_Mysql - Fatal编程技术网

Php 群发电子邮件错误,根据找到的记录数重复内容

Php 群发电子邮件错误,根据找到的记录数重复内容,php,mysql,Php,Mysql,我在向特定用户发送电子邮件时没有遇到任何问题,但当我尝试向数据库(MYSQL)中找到的所有电子邮件发送类似消息时,问题就出现了 如果我在数据库中找到了4个用户,它仍然会发送给所有4个用户,但电子邮件中类似的内容会重复4次。如果找到250个用户,则有250个重复内容 代码的代码片段就是这样,我一直在干预它,对它进行了多次测试,我的想法都没有了。感谢您的关注,非常感谢您的帮助 } elseif ($temptarget == 'Parents'){ $g1chk = mysql_query("SE

我在向特定用户发送电子邮件时没有遇到任何问题,但当我尝试向数据库(MYSQL)中找到的所有电子邮件发送类似消息时,问题就出现了

如果我在数据库中找到了4个用户,它仍然会发送给所有4个用户,但电子邮件中类似的内容会重复4次。如果找到250个用户,则有250个重复内容

代码的代码片段就是这样,我一直在干预它,对它进行了多次测试,我的想法都没有了。感谢您的关注,非常感谢您的帮助

} elseif ($temptarget == 'Parents'){

$g1chk = mysql_query("SELECT * FROM wmsidb WHERE s_stat='ACTIVE'");
$g1found = mysql_num_rows($g1chk);

While ($rowg1 = mysql_fetch_array($g1chk)){

   $tempemail1 = $rowg1['g1_email'];
   $tempemail2 = $rowg1['g2_email'];

   $comments = (stripslashes($_POST['message']));

   $to = "Parent <$tempemail1>, Parent / Guardian <$tempemail2>" . "\r\n";
   $subject = "[$anndate] Announcement ::: $temptitle";

   // Main Headers
   $headers = "MIME-Version: 1.0" . "\r\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";

   // Additional Headers
   $headers .= "From: Contact Us <mailer@mailer.com>" . "\r\n";

   $message .= "
   <table align='center' border='0' width='100%' cellpadding='6'>
   <tr><td width='100%' align='left' bgcolor='#33327e'><font face='Arial' size='4' color='#ffffff'><b>" . strtoupper($temptitle) . "</b></font></td></tr></table>

   <table align='center' border='0' width='100%' cellpadding='3'>
   <tr><td width='10%' align='right'><font face='Arial' color='#636363'> date </font></td><td width='90%' align='left'><font face='Arial'>" . $tempdd . " " . strtoupper($tempmm2) . " " . $tempyear . "</font></td></tr>
   <tr><td width='10%' align='right'><font face='Arial' color='#636363'> posted by </font></td><td width='90%' align='left'><font face='Arial'>" . $temppost . "</font></td></tr>
   <tr><td width='10%' align='right' valign='top'><font face='Arial' color='#636363'> message </font></td><td width='90%' align='left'><font face='Arial'>embedded below...</font></td></tr>
   </table>

   <br/>

   <table align='center' style='border:1px solid grey' width='95%' cellpadding='18'>
   <tr><td width='100%' align='left'><font face='Arial'>" . $comments . "</font></td></tr>
   </table>

   <br/>";


   if ($tempfeedback == 'Yes'){

   $message .= "
   <table align='center' border='0' width='100%' cellpadding='3'>
   <tr><td width='10%' align='right'><font face='Arial' color='#636363'> feedback </font></td><td width='90%' align='left'><font face='Arial'>We need you to provide us a response to announcement above.</font></td></tr>
   <tr><td width='10%' align='right'><font face='Arial' color='#636363'></font></td><td width='90%' align='left'><font face='Arial'>Please complete the 'Feedback Form' found in the link below. Thank you!</font></td></tr>
   <tr><td width='10%' align='right'><font face='Arial' color='#636363'> link </font></td><td width='90%' align='left'><font face='Arial'><b><a href='' target='_blank'>link</a></b></font></td></tr>
   </table>";

   } else {

   $message .= "
   <table align='center' border='0' width='100%' cellpadding='3'>
   <tr><td width='10%' align='right'><font face='Arial' color='#636363'> feedback </font></td><td width='90%' align='left'><font face='Arial'>No feedback required.</font></td></tr>
   </table>";

   }


   $message .= "
   <p><font face='Arial'><br/>

   <br/><br/>

   Footer with contact information

   </font></p>";


   mail ($to,$subject,$message,$headers);

}

   echo "<tr><td width='80%' align='right'><font face='Arial' color='#636363'>" . $g1found . " emails sent to parents / guardians </font></td><td width='20%' align='middle'><font face='Arial'>OK</font></td></tr>";
   echo "<tr><td width='80%' align='right'><font face='Arial' color='#252525'>module terminated</font></td><td width='20%' align='middle'><font face='Arial'></font></td></tr>";

   echo "</table>";
}elseif($试探目标=='Parents'){
$g1chk=mysql_query(“从wmsidb中选择*,其中s_stat='ACTIVE'”);
$G1FOND=mysql\u num\u行($g1chk);
While($rowg1=mysql\u fetch\u数组($g1chk)){
$tempemail1=$rowg1['g1_email'];
$tempemail2=$rowg1['g2_email'];
$comments=(带斜杠($_POST['message']);
$to=“家长、家长/监护人”。\r\n”;
$subject=“[$anndate]公告::$tentitle”;
//主标题
$headers=“MIME版本:1.0”。\r\n”;
$headers.=“内容类型:text/html;字符集=iso-8859-1”。\r\n”;
//附加标题
$headers.=“发件人:联系我们”。\r\n”;
$message.=”
“.strtoupper($tentitle)。”
日期:“$tempdd.”.strtoupper($tempmm2)。“$tempyear.”
由“$temppost”发布
下面嵌入的消息。。。

“$comments。”
“; 如果($tempfeedback=='Yes'){ $message.=” 反馈我们需要您对上述公告做出回应。 请填写下面链接中的“反馈表”。谢谢! 链接 "; }否则{ $message.=” 反馈无需反馈。 "; } $message.=”


带有联系信息的页脚

”; 邮件($to、$subject、$message、$headers); } 回显“$g1found.”发送给家长/监护人的电子邮件正常; 回显“模块终止”; 回声“;
当然可以


每次循环运行时都会填充变量消息,因此在每个循环开始时,请执行:
$message=“”;

您应该签出MailChimp。