Copy link to clipboard
Copied
i have a form that needs to be emailed and it as products attached to it. however i have a repeat region to list all the products but when i email it ithe email only shows the first item on the list.
below is the form set up
//emailer
// Email new tenant information
$to = 'sales@domain.com';// . ',' . '$row_rsOrder["Email"]';
//$to = $row_rsOrder["Email"];
$subject = "Your Order Details";
$message = "
<html>
<head>
<title>Dear ".$row_rsOrder['FirstName'].$row_rsOrder['LastName']." please see your Order Details Below</title>
</head>
<body>
<img src=\"http://www.website.com/images/logoBLPP.jpg\" alt=\"" />
<h2>Your B Order".$row_rsOrder['OrderID']."</h2>
<table width='800' border='0' cellspacing='0' cellpadding='0'>
<tr><td><p>Thank you for shopping below are you details of the order you have recently placed. If you have any questions please contact us</p>
<br />
</a></p>
<tr><td></td></tr></table>
<table width='980' border='1' cellspacing='0' cellpadding='10'>
<tr valign='top'>
<td bgcolor='#E9E9E9' class='header1'>Customer Name</td>
<td class='text'>".$row_rsOrder['FirstName'] . $row_rsOrder['LastName']."</td>
<td bgcolor='#E9E9E9' class='header1'>Order ID</td>
<td bgcolor='#E9E9E9' class='text'>".$row_rsOrder['OrderID']."</td>
<td bgcolor='#E9E9E9' class='header1'>Order Status</td>
<td class='text'>".$row_rsOrder['TransactResult']."</td>
</tr>
<tr valign='top'>
<td bgcolor='#E9E9E9' class='header1'>Email</td>
<td class='text'>".$row_rsOrder['Email']."</td>
<td bgcolor='#E9E9E9' class='header1'> </td>
<td class='text'> </td>
<td bgcolor='#E9E9E9' ><span class='header1'>Order Date</span></td>
<td class='text'>".makeDateTime($row_rsOrder['OrderDate'], '%#d %B %Y', true)."</td>
</tr>
<tr valign='top'>
<td bgcolor='#E9E9E9' class='header1'>Shipping Address</td>
<td class='text'><p>".$row_rsOrder['Address']."</p>
<p>".$row_rsOrder['Town']."</p>
<p>".$row_rsOrder['PostCode']."</p>
<p>".$row_rsOrder['Country']."</p>
<p> </p></td>
<td> </td>
<td> </td>
<td colspan='2' align='right' valign='bottom'><span class='header'> ORDER TOTAL:".DoFormatCurrency($row_rsOrder['Total'], 2, ',', '.', '£ ', '')."<br />
</span><span class='text'>Shipping:".DoFormatCurrency($row_rsOrder['Shipping'], 2, ',', '.', '£ ', '')."</span><span class='header'><br />
</span></td>
</tr>
<tr valign='top'>
<td bgcolor='#E9E9E9' class='header1'>Product ID</td>
<td bgcolor='#E9E9E9' class='header1'>Product Description</td>
<td bgcolor='#E9E9E9' colspan='2' class='header1'>Size</td>
<td bgcolor='#E9E9E9' ><span class='header1'>Quantity</span></td>
<td bgcolor='#E9E9E9' align='right'><span class='header1'>Price</span></td>
</tr>
<?php do { ?>
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>
<?php } while ($row_rsOrder = mysql_fetch_assoc($rsOrder)); ?>
<tr valign='top'>
<td class='text'> </td>
<td class='text'> </td>
<td colspan='2' class='text'> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: company name <email@domain.com>' . "\r\n";
$send = mail($to, $subject, $message, $headers);
Yes, ALL product information in the database were retrieved and sent to the email. Only 3 products for testing purposes.
I just tested it down to the do-while loop. The html table code after that is missing.
You have to bare in mind this is a crude test. The database set up query is not as complex as yours is so that may be why its working but certainly breaking up the 'message' is the way to go. I may try and get the products from another table tomorrow if I have time to test.
The html code and co
...Copy link to clipboard
Copied
Jonathan Fortis wrote:
let me know how you get on please
I split the products and customer information into two tables and it still works.
The sql query still isn't anywhere near as complex as yours is though.
What we have established is the do-while loop does work if you break out and back into the php again.
What I would do is a test using two simple tables first to get the do-while loop working. Once that is working you have a template. Then its a case of building the sql query.
Copy link to clipboard
Copied
yeah, trouble with that this is a live site so might be a bit tricky.
Copy link to clipboard
Copied
ok i used your code then changed your SQL for mine and it worked. Thanks so much
the only thing that i am having trouble is i have the order details diplayed on the page that sends the email however if i echo any informatioin out below the email code nothing shows. if i add an echo before the email it shows. its like it is killing the order after the email?
Copy link to clipboard
Copied
i added the emailer at the end of the page and now it works thanks for your help
Copy link to clipboard
Copied
To enable you to check if your page is sending the full repeat content, put this on your thank you page for force it to print it to the page:
<?php @session_start(); var_dump($_SESSION); ?>
You'll get a load of code, but you will also see what content you are getting such as email addresses, time sent and the contents of the body.
Copy link to clipboard
Copied
ok i tried this and got the following
array(2) { ["MM_Username"]=> string(6) "bobby12" ["MM_UserGroup"]=> string(0) "" }
Notice: Undefined variable: message in E:\Domains\b\website\user\htdocs\admin\order-details-sent.php on line 136
line 136 is <td class='text'>".$row_rsOrder['ProductID']."</td>