php
2017-08-14 18 views 0 likes 
0

保留中のタスクを通知する複数の受信者にメールを送信する必要があります。異なるコンテンツを持つ複数の受信者にメールを送信する

これは、各受信者の保留中のタスクを照会するための配列です。

$pending = array(
"select * from user WHERE status='processing' and reason!='Out of island'", 
"select * from user WHERE status='processing' and reason!='Out of island'", //DGM-HR 
"select * from user WHERE status='new'", //DGM-ITAS 
"select * from user WHERE status='processing' and reason='Out of island'", //Manager-HR 
"select * from user where CRM_Status='pending'", //CRM-Eng 
"select * from user where OSS_Status='pending'", //OSS-Eng 
"select * from user where BSS_Status='pending'" //BSS-Eng 
); 

//各クエリから結果を取得し、別の配列に渡します。この配列は機能しません。

​​

//結果を取得して該当する受信者にメールを送信します。しかし、私はまだ受信者の部分を設定していません。

+0

mysqli_query()は、複数のクエリの結果をアセンブルしません。複数のクエリを実行するか、複合WHERE句を使用して単一のクエリを使用する必要があります。 –

答えて

0

複数のクエリを実行してDBに問い合わせるのではなく、一般的なクエリを実行してより高速にアクセスできるように結果にフィルタをかけるだけです。いったん一般的なクエリの配列を取得したら、何でもできます。

0

私はこのようなコードをこのように変更しました。

$pending = array(
"select * from user WHERE status='processing' and reason!='Out of island'", 
"select * from user WHERE status='processing' and reason!='Out of island'", //DGM-HR 
"select * from user WHERE status='new'", //DGM-ITAS 
"select * from user WHERE status='processing' and reason='Out of island'", //Manager-HR 
"select * from user where CRM_Status='pending'", //CRM-Eng 
"select * from user where OSS_Status='pending'", //OSS-Eng 
"select * from user where BSS_Status='pending'" //BSS-Eng 
); 

//$pending = implode("\r\n", $pending); 
$result = mysqli_query($dbcon,$pending[0]); 
$result1 = mysqli_query($dbcon,$pending[1]); 

$address=array('mail_1','mail_2'); 
if(!$result||!$result1) 
{ 
    die('Could not get data: ' . mysqli_error()); 
} 
else 
{ 
    $count= mysqli_num_rows($result); 
    $count1= mysqli_num_rows($result1); 
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';*/ 

    $count_c=array($count,$count1); 
    foreach($count_c as $cunt) //Not working 
    { 
     foreach($address as $addr) 
     { 
      $mail->addAddress($addr, 'Mailer'); 
      $mail->Subject = 'Notification: User Management System'; 
      $mail->Body = 'Dear User, <br> <br>You have '.$cunt.' records which is pending for your approval.<br> Please engage for the relevant tasks.<br><br>'; 
      $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 
     } 
    } 
} 

まだアレイ部分が機能していません。

関連する問題