doutan3040 2015-06-21 08:39
浏览 32
已采纳

在变量php中重复区域

Trying to build contact page. I would like to be able to send multiple emails in one time. email addresses have been pulled in from database. I am managing getting them all with do while. However to add "bcc" all addresses I need them to be in one variable for example $emails. I cannot seem to figure out how to do that. This is what I have so far:

 $username = $_POST['Username'];
    $email = $_POST['email'];
    $to="email goes here"; 
    $from= $_POST['email'];
    $subject= "Raiding Team Announcement";
    $footer="© Copyright 2015 All Rights Reserved "; 

            $message .= '<html><body>';
            $message .= '<div style="width:100%; background-color:#333;">';
            $message .= '<h1 style="font-size:50px; color:#FFCC00; text-   align:center; display:block; padding-bottom:15px; border-bottom:1px solid #AA0114; ">HellscreamsFury</h1>';
            $message .='<h2 style="font-size:32px;color:#f37e0e; text-align:center;">' .$_POST["Username"].' says:</h2>';
            $message .='<div style="margin:30px; padding:10px; border:1px solid #404040; margin-bottom:50px;">';
            $message .='<p style="font-size:18px; color:#ccc;">' .$_POST["message"]. '</p>';
            $message .= '</div>';
            $message .= '<div style="border-top:1px solid #AA0114;">';
            $message .='<p style="font-size:12px; color:#fff; text-align:center; padding: 20px 0 50px 0;">' .$footer. '</p>';
            $message .= '</div>';
            $message .= '</div>';
            $message .= '</body></html>';
            $headers  .= "From: " . $from . "
";
            $headers .= "MIME-Version: 1.0
";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1
";
            if(mail($to,$subject,$message,$headers)){
    header("Location: ../announcments.php?aid=43");
}
else{
header("Location: ../announcments.php?aid=44"); 
}

This snippet pulls in my emails:

    <?php do { ?>
  <?php echo $row_rs_contact_team['email']; ?>
  <?php } while ($row_rs_contact_team = mysql_fetch_assoc($rs_contact_team)); ?>

I would need them to sit in one variable - let's say $emails. How do I do that? Also emails are pulled in while checking user_id, but sometimes user_id repeats - is there a way to pull that email in once instead of pulling let's say three times?

  • 写回答

1条回答 默认 最新

  • duanlao6573 2015-06-21 09:38
    关注

    Do can do it by iterating it into a while loop and concat it and adding a comma near to it.

    $CountingQuery = "SELECT * FROM users";
    $ExecutingCountingQuery = $Connection->query($CountingQuery);
    $Bcc = ''; // Declaring a Variable
    while($row = $ExecutingCountingQuery->fetch_array())
      {
      $Bcc .=$row['email'].',';
      }
    echo $Bcc;  // Now $Bcc is your expected output
    //The output will be something like
    
    //sa@sysaxiom.com,test@sysaxiom.com,demo@sysaxiom.com,admin@sysaxiom.com,
    

    Note :

    I don't know what name you use to store the email coloumn. So i used the name email for the email column.

    Also I have used * where you can replace it for your need.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记