I'm trying to figure out how to use a fetch_array to build out the body of an email message that will be automatically generated.
Here is what I have so far. For truncating purposes, I'll leave out some of the variable. $query is a pretty massive query from a couple of tables, and it is confirmed to work properly.
inc/connect.inc is a standard connection script that is included.
include("inc/connect.inc"); //standard connect script
$date=date("m-d-Y");
$head="<table border=\"1\"><tr><td>Agent Name</td>...</td></tr>";
$query = "SELECT avaya.agent_name, data.tech, ... GROUP BY data.tech";
$result=mysql_query($query);
$foot="</table>";
$to = "xxx@xxx.com";
$subject = "Morning Report - $date";
$msg = "
<html>
<body>
<h3>Aux and Production Report</h3>
$head".
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$msg .="<tr><td>{$row['agent_name']}</td>...</td></tr>". }
$msg .="$foot
</body>
</html>
";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From\072 \074xxx@xxx.com\076\nReply-To\072 \074xxx@xxx.com\076";
$config = "-f xxx@xxx.com";
mail($to, $subject, $msg, $headers, $config);
If I leave out the while statement I get a normal email, but if I try to run that array I get nothing. I'm running this as a function in a file required on the page I'm trying to run this script on.
Any direction would be great.
Thanks.