解决方案 »

  1.   

    简单说一下2个方法,可试试看有问题再讨论1. 你上一个帖子提到的用2页处理
    从 A.php 获取10条email资料 (select email from bl_email where ..... )
    然後sumit表单POST到B.php处理寄送动作2. 用ajax不换页处理
    从 A.php 获取10条email资料 (select email from bl_email where ..... )
    按下按钮後用ajax post 10条email到後端 B.php处理寄送动作
      

  2.   

    回复1楼
    为何只读取到一条记录
    <?php  
     $conn=mysql_connect("localhost","root","");//连接数据库
     mysql_select_db("email",$conn);//连接哪个库
     mysql_query("set names utf-8");//编码方式 
     $sql="select * from bl_email";//查询那个表
     $result=mysql_query($sql,$conn);
     while($array=mysql_fetch_array($result)){
      $email=$array["address"];
     };
     print_r("$email");                 
    ?> 
      

  3.   


    用这句看看印出什麽结果
    print_r(mysql_fetch_array($result));
      

  4.   

    难道错误在这句吗
    打印的结果
    Array ( [0] => 2 [id] => 2 [1] => tom [name] => tom [2] => [email protected] [address] => [email protected] [3] => 2345 [tel] => 2345 ) 
      

  5.   

    回复3楼
    前面没看,4楼的打印是没加while的
    加了while的
    打印出 mysql_fetch_array(Resource id #4) 
      

  6.   

    回复3楼
    问题找到了,打印没有放在while里面
      

  7.   

    我直接把上面取得变量$email加到了这个上面
    $mail->AddAddress("$email","h"); //添加收件人
    这样可以提交,就是邮件发不过去
      

  8.   


    $mail->AddAddress("$email","h"); 
    改为
    foreach($email as $em){
        $mail->AddAddress("$em","h"); 
    }
      

  9.   


      if(!$mail->Send()) {
          echo "发送失败: " . $mail->ErrorInfo;
      } 
      

  10.   

    回复11楼和12楼
    提示:You must provide at least one recipient email address. 
    为什么没有获得地址
    程序
               $conn=mysql_connect("localhost","root","");//连接数据库
       mysql_select_db("email",$conn);//连接哪个库
       mysql_query("set names utf-8");//编码方式 
       $sql="select * from bl_email";//查询那个表
       $result=mysql_query($sql,$conn);
       while($array=mysql_fetch_array($result))
              {
          $email=$array["address"];
       }if(is_array($email))
       {
       foreach($email as $em)
    {
       $mail->AddAddress("$em","h");
    }
       } if(!$mail->Send()){
              echo "发送失败: " . $mail->ErrorInfo;  
    ?>
    <script type="text/javascript">
    alert('无法发送邮件,错误信息:'.$mail->ErrorInfo);
    window.location = 'send.php';
    </script>
    <?php
         } else {
             //echo "邮件已经发送";
    ?>
    <script type="text/javascript">
    alert('邮件发送成功');
    window.location = 'send.php';
    </script>
    <?php
         }
    ?>
      

  11.   

    if(is_array($email))如果$email不是array的情況,你沒有寫。
      

  12.   

    问题已经解决
    在while上面给$email定义一个空的数组
    就解决了
    前面应该问题是在
    打印在while里面可以出来多个值
    在外部打印就只出来一个值
    然后下面的$mail->AddAddress("$em","h");在按照版主的加个foreach循环
    就可以群发了
      

  13.   

    请教下楼主,你所说的 在while上面给$email定义一个空的数组是下面这样吗?
    我也是新手 while($array=mysql_fetch_array($result))
              {
          $email[]=$array["address"];
       }
      

  14.   

    回复16楼
    我是这样做的
    $email=array();
    while($row=mysql_fetch_array($result))
    {
        $email[]=$row["address"];
     }
      

  15.   

    while之前的数组应该不用定义吧?$email[]会自动创建一个数组。