php - Sending emails to multiple recipients with different content -


i need send mails multiple recipients notifying pending tasks.

this array querying pending tasks each recipient.

$pending = array( "select * user status='processing' , reason!='out of island'", "select * user status='processing' , reason!='out of island'", //dgm-hr  "select * user status='new'", //dgm-itas "select * user status='processing' , reason='out of island'", //manager-hr "select * user crm_status='pending'",  //crm-eng "select * user oss_status='pending'",  //oss-eng "select * user bss_status='pending'"  //bss-eng ); 

//retrieve results each query , pass array. array not working.

$pending = implode("\r\n", $pending); $result = array( mysqli_query($dbcon,$pending) ); 

//getting result , send mail relevant recipient. haven't set recipient part yet.

foreach($result $result1) {         if(!$result1)          {             die('could not data: ' . mysqli_error());         }         else         {             foreach($result1 $count)             {                 $count= mysqli_num_rows($result1);                 $mail->addaddress('to_mail', 'to'); //only single recipient                 $mail->subject = 'notification: user management system';                 $mail->body    = 'dear user, <br> <br>you have '.$count.' records pending approval.<br> please engage relevant tasks.<br><br>';                 $mail->altbody = 'this body in plain text non-html mail clients';             }         }    } 

instead of running multiple queries , asking db, run general query , filter in results faster access. once have arrays general query can whatever want


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -