phpmailer to send html table in message
Posted: Thu Aug 26, 2010 11:02 pm
I am trying to show a table in a html email using phpmailer. I am new to php and mysql (and html for that matter lol)... I can get it to show one record fine, but when I get to the loops and array statement (???), I keep getting server 500 records, (i believe i may not be putting an end to the loop perhaps) but have not posted any of my attempts and I am hoping someone will head me in the right direction as to how to get this to work.
I have included snippets of my code that does work (and emails one record just how i want it to go) and the steps taken to get there.
1) $row->id gets sent to email function (with other data) when user presses save on a form.
2) Here is mysql statement to get the data I want to show in the table from the database
3. here is where i am having trouble and could use a point in the right direction
4. To create a table with a single record - I am using this and it works perfect. I need to obviously change this to include subsequent lines of the string
thanks in advance!
I have included snippets of my code that does work (and emails one record just how i want it to go) and the steps taken to get there.
1) $row->id gets sent to email function (with other data) when user presses save on a form.
2) Here is mysql statement to get the data I want to show in the table from the database
Code: Select all
//Get Service Details
$row->id = strip_tags($_POST['id']);
$query = "SELECT * FROM #__jservicerelation INNER JOIN #__jservices on #__jservicerelation.serviceid = #__jservices.id WHERE invoiceid=$row->id";
$database->setQuery($query);
$appliedservices = $database->loadAssoc();
$num=mysql_numrows($appliedservices);
$qty = $appliedservices['quantity'];
$desc = $appliedservices['productname'];
$list = $appliedservices['listprice'];
$totalcost = $appliedservices['listprice'] * $appliedservices['quantity'];4. To create a table with a single record - I am using this and it works perfect. I need to obviously change this to include subsequent lines of the string
Code: Select all
$message .= '<table rules="all" style="border: 1px solid #DDD;" cellpadding="10">';
$message .= "<tr><td><strong>Qty</strong> </td><td><strong>Description</strong> </td><td><strong>Net Price</strong> </td><td><strong>Total</strong> </td></tr>";
$message .= "<tr><td>" . strip_tags($qty) . "</td><td>" . strip_tags($desc) . "</td><td>" . strip_tags($list) . "</td><td>" . strip_tags($totalcost) . "</td></tr>";
$message .= "</table>";