0

我有一个带有下拉列表的 HTML 表单,其中包含从数据库中填充的整个买家列表。除此之外,我在下拉列表的顶部有一个选项,例如:

   <select name="sms_buyer">
          <option value="alll">ALL</option>
              <?php 
                  require_once '../model/notifications.php';
                  @$result2=  Notifications::getAllBuyers();
                  while($value2=mysql_fetch_assoc($result2)){
              ?>
          <option value="<?php echo $value2['buyer_code']; ?>">
                 <?php echo $value2['buyer_name'] ?>
          </option>
          <?php } ?>
   </select>

在控制器中,我有以下代码段:

  function sendNotificationSMS(){

        $sms_buyer=$_REQUEST['sms_buyer'];
        $sms_message=$_REQUEST['sms_message'];
        $sender='MY CLIENT';
        $url='http://localhost:9333/ozeki?';
        $url.="action=sendMessage";
        $url.="&login=admin";
        $url.="&password=abc123";

        $obj=new Notifications();

        if($sms_buyer=='alll'){
            require_once '../model/notifications.php';
            $obj=new Notifications();
            $result=$obj->getAllBuyers();

            while($value=mysql_fetch_assoc($result)){
                $rec[]=$value['tel_no'];
            }

            foreach ($rec as $recepient) {
                $url.="&recepient=".urlencode($recepient);
            }
        }
        else{
            $res=$obj->getBuyerTelNo($sms_buyer);
            $sms=mysql_fetch_assoc($res);
            $recepient=$sms['tel_no'];
            $url.="&recepient=".urlencode($recepient);
        }

        $message=$sms_message;
        $message.=' Thank You.';


        $url.="&messageData=".urlencode($message);
        $url.="&sender=".urlencode($sender);
        file($url);
        header("location:../view/send_notifications.php?s=3#sent");
  }

如果我键入 print_r($url),则不会出现我想要的输出...将 SMS 发送给单个接收者就可以了。问题是向多个收件人发送短信。

任何帮助表示赞赏。谢谢。

4

1 回答 1

0
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try {
        String sel = "select parents.parent_contact, Parents.names, students.admno, Students.Names, Examination_lower.Mathematics, Examination_lower.Kiswahili, Examination_lower.English, Examination_lower.Science, Examination_lower.Religion, Examination_lower.Social_studies, Examination_lower.total from parents, students, Examination_lower where parents.parent_contact=students.parent_contact and Examination_lower.admno=students.admno";
        pst = conn.prepareStatement(sel);
        smnt = conn.createStatement();
        rs = pst.executeQuery();
        while (rs.next()) {
            String contact = rs.getString("parent_contact");

            String smsSender = "+2547xxxxxx66";
            String smsReceiver = contact;
            String message = jTextArea1.getText();
            String sqlInsert = "INSERT INTO "
            + "messageout (Sender,receiver,msg,status) "
            + "VALUES "
            + "('" + smsSender + "','" + smsReceiver + "','" + Message + "','send')";

            if (smnt.executeUpdate(sqlInsert) != 0) {
                System.out.println("OK");

            } else {
                System.out.println("ERROR");
            }

        }

    } catch (Exception ex) {
        System.out.println("Exception: " + ex.getMessage());
        ex.printStackTrace();
    } finally {
        try {
            pst.close();
            smnt.close();
        } catch (Exception e) {
        }
    }
} 
于 2015-11-27T11:10:08.257 回答