Jump to content

PHPmailer: How do I display arrays?


Jack.Straw

Recommended Posts

I have a scenario where i'll need an email to be sent containing selected contents of a database.  I've tried building the email as a variable and then using the variable as the email body, but I can't seem to figure out how to force a carriage return.  I would like all items listed on a separate line.  Can I somehow put conditionals and loops within the body tag? 

This is the logic behind what i'm trying to do:
[code]
$result=mysql_query("SELECT * from SoldItems WHERE OrderNumber='$userID'");
while ($row=mysql_fetch_array($result)) {
  //DisplayInEmail: $row[Qty] - $row[Item];
}
[/code]

I tried doing something like:
[code]
$result=mysql_query("SELECT * from SoldItems WHERE OrderNumber='$userID'");
while ($row=mysql_fetch_array($result)) {
  $Display=$Display."$row[Qty] - $row[Item]<br>";
}
$mailer->Body = "$Display";
[/code]
... but that relies on html for the carriage return and I need the emails in plain text.


Thanks in advance for any advice you can offer!
-Jack
Link to comment
https://forums.phpfreaks.com/topic/29229-phpmailer-how-do-i-display-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.