title: how to send email from results generated as array from mysql query
body: <p>i am using the following query:-</p>
  
  <pre><code>$qry=mysql_query("SELECT item,quantity,price,(quantity * price) as total FROM saleitems_T WHERE invoice = '$inv' ");
  </code></pre>
  
  <p>i am trying to use the while loop inside the mail body but it does not work. following is the code.</p>
  
  <pre><code>$to="someone@somewhere.com";
  $headers="Content-type: text/html\r\n";
  $body = '
  &lt;html&gt; &lt;body&gt;
  Invoice details are as follows.&lt;br /&gt;
  '.while($row = mysql_fetch_array($qry)){
  echo "&lt;table&gt;&lt;tr&gt;&lt;td&gt;";
  echo $row['item'];
  echo "&lt;/td&gt;&lt;td&gt;";
  echo $row['quantity'];
  echo "&lt;/td&gt;&lt;td&gt;";
  echo $row['price'];
  echo "&lt;/td&gt;&lt;td&gt;";
  echo $row['total'];
  echo "&lt;/td&gt;&lt;/tr&gt;";} .'
  &lt;/table&gt;&lt;/body&gt;&lt;/html&gt;';
  
  mail($to,$body,$headers);
  </code></pre>
  
  <p>the no of lines retrieved varies on each invoice. Now i want to send the results as an email. any help with sample code would be greatly appreciated.</p>