Wednesday 15 August 2012

php - Email individual results (10 results = 10 email) instead of 1 email with all data in it -


I have the following script which tells the query as a database and output result email, however, Would like to send (10 results = 10 emails) instead of an email with all the results.

Can any kind of spirit tell me in the right direction? It's okay to me now. Should I get the result?

  & lt ;? Php // authentication database for $ hostname = "xxxx"; $ Username = "xxxx"; $ Password = "xxxx"; // database $ dbhandle = mysql_connect ($ hostname, $ user name, $ password) or connection to die ("unable to connect to MySQL"); // $ selected = mysql_select_db ("test", $ dbhandle) or select a database to die ("Example could not be selected"); // execute SQL queries and Records records $ result = mysql_query ("Choose * FROM tbl_assignees WHERE work_pass_expiry = DATE (now ())"); If (! $ Results) {// your error dying ('query failed.'); } // variable email message $ = 'some email address'; $ EmailBody = ""; // Get data from database ($ line = mysql_fetch_array ($ result)) {$ subject = $ line ['name']. "'S" "The job is nearing soon"; $ EmailBody = "Manufacturer:". $ Line ['rlog_create_user_name']. "\ N"; $ EmailBody = "Company:". $ Line ['company']. "\ N"; $ EmailBody = "Assign name:" $ Line ['name'] "\ N"; $ EmailBody = "Finn no:". $ Line ['fin_no_'] "\ N"; $ EmailBody = "Relationships:" $ Line ['relationship']. "\ N"; $ EmailBody = "Main Holder Fin:". $ Line ['main_holder_fin']. "\ N"; $ EmailBody = "Work pass type:" $ line ['work_pass_type']. "\ N"; $ EmailBody = "Job closeout:" $ line ['work_pass_expiry']. "\ N"; $ EmailBody = "Passport Number:" $ Line ['passport_no_']. "\ N"; $ EmailBody = "Passport termination:" $ line ['passport_expiry']. "\ N"; $ EmailBody = "DOB:". $ Line ['d_o_b']. $ EmailBody. = "Contact:". $ Line ['Contact']. "\ N"; $ EmailBody. = "Email:" $ line ['email']. "\ N"; $ EmailBody = "Note:". $ Line ['note'];} $ headers = ':: task pass notification system & lt; no-reply @ someemailaddress & gt; "E-mailer: php / 'phpversion (); if (mail ($ $, $ theme, $ emailboard, $ header)) {echo:' someemailaddress'" \ r \ n " $ EmailBody; echo 'Email successfully sent!'; Else {echo $ emailBody;} ('Failure: Email was not sent!'))} // Close the connection mysql_close ($ dbhandle);? & Gt; < / Code>   

Add the mail function inside this loop:

  while ($ row = mysql_fetch_array ($ result)) {$ to = 'some email address'; // is good if you get an e-mail id from the database $ emailBody = ""; // every Clear body of email / ** Your email subject and body here ** / $ headers = ': The work has a notification system & lt; no-reply @ someemailaddress & gt;' "E-mailer: php / 'phpversion (); if (mail ($ $, $ theme, $ emailboard, $ header)) {echo:' someemailaddress'" \ r \ n " $ EmailBody; echo 'Email successfully sent!';} Else {echo $ emailBody; die ('Failure: Email was not sent!')}}}   

Received from this database Records will send the number of emails equal to.

No comments:

Post a Comment