I am trying to send email and insert an array of results within in the mail body?
I am using a while loop off of a sql query and then mailing it using
phpmailer. (http://phpmailer.sourceforge.net/)
Below is the code i used to query the database and get the array of results:
$result_get = mysql_query("QUERY HERE");
$i = "0";
echo mysql_error();
while ($row_get = mysql_fetch_array ($result_get))
{
// HTML body
$id = $row_get['id'];
echo $id."<br><br>";
$result = mysql_query("SELECT BLAH, BLAH WHERE = '$id'");
while ($row = mysql_fetch_array ($result)) {
echo $row[name]." job_super ".$row[super]."<br>";
}
}
}
From there my problem is getting the array contents into the mail body variable.
if i change the above to:
while ($row = mysql_fetch_array ($result)) {
$mail_body = $row[name]." job_super ".$row[super];
}
It will not display the array all I see is a one.
So basically what i am doing is first running a query to get an email address and then running a query to get a list of names related to the email address. From there i want to insert the list of names within the email and then loop through the list of emails.
I can get everything to print on the screen but i cant get it to insert the list of all the names related to that email address into a variable which could then be inserted into each mail as it loop through all the addresses.
Below is my mailer code.
$text_body = "This email is currently under development";
$body = $mail_body;
// Plain text body (for mail clients that cannot read HTML)
$text_body = $mail_body;
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"]);
if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "<br>";
echo "* ";
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
If anyone has any ideas please let me know.