Including a for each loop of array within PHP mail as HTML table
<p>This is the method I am attempting to use whilst trying to "send" a shopping cart to the admin. It may be an unorthodox method please any suggestions would be more than welcome. </p>

<p>This information is coming from a session plus a separate script which is all working well. It displays cart contents which I then am trying to send via email as well as some personal information:</p>

<pre><code>&lt;?php foreach ($quotes as $quote): ?&gt;
  &lt;tr&gt;
    &lt;td class="quoteTdL"&gt;&lt;h3&gt;&lt;?php echo htmlspecialchars($quote['name'], ENT_QUOTES,'UTF-8'); ?&gt;&lt;/h3&gt;&lt;/td&gt;
    &lt;td class="quoteTdR"&gt;&lt;p&gt;&lt;?php echo htmlspecialchars($quote['text'], ENT_QUOTES,'UTF-8'); ?&gt;&lt;/p&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;?php endforeach; ?&gt;
</code></pre>

<p>Essentially I would like to include this information within this cut down mail script:</p>

<pre><code>  //send email
  $to = "";

  $fname = $_REQUEST['fname'] ;
  $sname = $_REQUEST['sname'] ;
  $email = $_REQUEST['email'] ;
  $pnum = $_REQUEST['pnum'] ;
  $mnum = $_REQUEST['mnum'] ;
  $content = $_REQUEST['content'] ;

  $subject = 'Email from SAiGE Longlife website';

  $msg = '
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;SAiGE Longlife Decking enquiry&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;table width="600" border="0" align="center" cellpadding="10"&gt;
        &lt;tr&gt; 
          &lt;td colspan="2" align="center" bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#fff;"&gt;SAiGE Longlife Decking enquiry&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td width="200" bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;"&gt;Name:&lt;/td&gt;
          &lt;td width="400" bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;"&gt;';
        $msg .=$fname;
        $msg .='&amp;nbsp;';
        $msg .=$sname;
        $msg .='
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;"&gt;E-mail&lt;/td&gt;
          &lt;td bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;"&gt;';
        $msg .=$email;
        $msg .='
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;"&gt;Phone numbers:&lt;/td&gt;
          &lt;td bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;"&gt;';
        $msg .=$pnum;
        $msg .='
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;"&gt;';
        $msg .=$mnum;
        $msg .='
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td colspan="2" bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;"&gt;Message:&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td colspan="2" bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;"&gt;';
        $msg .=$content;
        $msg .=$cartHtml;
        $msg .='

          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/body&gt;
    &lt;/html&gt;
    ';
</code></pre>

<p>I have tried imploding and integrating the foreach side of things but to no luck and have spent a long time on it!</p>

<p>Is it possible to output the loop first as a variable and then include or is this unnecessary? </p>

<p>All help would be appreciated.</p>

<p>Many thanks,</p>

<p>Tom</p>
