Jump to content

[SOLVED] Sending an Email with MySQL data


$username

Recommended Posts

Hello All,

      I am setting up some email sending with PHP pulling info from MySQL.

I have one question on how to make the message body.

 

Here is the code I have.

What is the key to getting the PHP loop to be equal to a value.

 

$ToMail = '[email protected]';
$MsgSubject = "Daily Invoices Due";


$MsgBody = (
echo "<table>";
while($row589 = mysql_fetch_array($sql589)) {
echo "<tr>";
echo "<td>".$row589['PaymentInvoiceID']."</td>";
echo "<td>".$row589['PaymentDueDate']."</td>";
echo "<td>".$row589['PaymentPaid']."</td>";
echo "<td>".$row589['PaymentAccountID']."</td>";
echo "</tr>";
}
echo "</table>"
);

Link to comment
https://forums.phpfreaks.com/topic/126313-solved-sending-an-email-with-mysql-data/
Share on other sites

I want the value of $MsgBody = to

echo "<table>";

while($row589 = mysql_fetch_array($sql589)) {

echo "<tr>";

echo "<td>".$row589['PaymentInvoiceID']."</td>";

echo "<td>".$row589['PaymentDueDate']."</td>";

echo "<td>".$row589['PaymentPaid']."</td>";

echo "<td>".$row589['PaymentAccountID']."</td>";

echo "</tr>";

}

echo "</table>";

Maybe something like this?

I want the value of $MsgBody = to 
echo "<table>";
while($row589 = mysql_fetch_array($sql589)) {
echo "<tr>";
echo '<td>'.$row589[0].'</td>';
echo '<td>'.$row589[1].'</td>';
echo '<td>'.$row589[2].'</td>';
echo '<td>'.$row589[3].'</td>';
echo "</tr>";
}
echo "</table>";

$message = "</pre>
<table>";
while($row589 = mysql_fetch_array($sql589)) {
$message .=  "";
$message .= "".$row589['PaymentInvoiceID']."";
$message .= "".$row589['PaymentDueDate']."";
$message .= "".$row589['PaymentPaid']."";
$message .= "".$row589['PaymentAccountID']."";
$message .= "";
}
$message .= "</ta

 

If you use $message in your body variable for the mail function then it will display all this info throughout the loop.

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.