I am making a form where a user can build a shopping cart and then once they submit it, they are taken to a page that displays their final contents in their cart. Behind the scenes, PHP is sending an email to myself which needs to contain the exact same table that was already rendered on the page once however I do not want to have to rebuild the table again, I would like to use the one that was already built. I don't know how to do this. My code works and everything is how I want it so don't
Below is a sample of code kind of like I have built, I cut out the repeat stuff to make it easier to look at.
<table align="center" width="100%">
<thead align="center">
<tr>
<td style="border-color: #000000; background-color: #000000; color: #ffffff; border-style: solid; border-width: 1px;" class="head"><b>Product</b></td>
<td style="border-color: #000000; background-color: #000000; color: #ffffff; border-style: solid; border-width: 1px;" class="head"><b>Item ID</b></td>
<td style="border-color: #000000; background-color: #000000; color: #ffffff; border-style: solid; border-width: 1px;" class="head"><b>Quantity</b></td>
<td style="border-color: #000000; background-color: #000000; color: #ffffff; border-style: solid; border-width: 1px;" class="head"><b>Cost</b></td>
</tr>
</thead>
<tbody>
<?php
$i = 0;
$cmf073 = mysqli_result($result, $i, "cmf073");
$cmf073total = mysqli_result($result, $i, "cmf073total");
if($cmf073 > 0)
{?>
<tr>
<td align="center" style="border-color: #000000; background-color: #ffffff; border-style: solid; border-width: 1px;" class="body">
Printable 3-Up Certified Mail® Form
</td>
<td align="center" style="border-color: #000000; background-color: #ffffff; border-style: solid; border-width: 1px;" class="body">
CMF-073
</td>
<td align="center" style="border-color: #000000; background-color: #ffffff; border-style: solid; border-width: 1px;" class="body">
<?php echo number_format($cmf073 * 1000, 0) ." Forms";?>
</td>
<td align="center" style="border-color: #000000; background-color: #ffffff; border-style: solid; border-width: 1px;" class="body">
$<?php echo number_format($cmf073total, 2);?>
</td></tr>
<?php
}
echo "<tr border='0'><td></td><td></td><td></td><td align='center'><b>Cost Estimate: ";
echo "$".number_format($total, 2)."</b><br />
<font style='font-size: 8px;'>Plus Tax, Shipping and Handling</font></td></tr></tbody></table>";
}
$email = "x@y.net";
$subject = "New Customer Order Request from $company" ;
$message = "A new order request has been submitted on y.net</br></br>
Contact Info:</br>
$firstName $lastName</br>
$phone | $email</br>
$company</br>
$address1</br>
$address2</br>
$city, $state $zip";
$headers = 'From: x@y.net' . "
" .
'Reply-To: x@y.net' . "
" .
'Content-type: text/html; charset=utf-8' . "
" .
'X-Mailer: PHP/' . phpversion();
mail($email, $subject, $message, $headers);
So I need the table that was already generated at the top of the code to be placed in the bottom of the email $message. But I don't want to regenerate everything again since PHP has already created the table that I need. Sorry if this is confusing, I don't really know how to explain it. Thanks.