Rather then echo'ing the result, why not save it to a variable and then send that variable into the e-mail, i.e.
$table .= "<tr><td>$adclass</td><td>$description</td></td>$listings</td></tr>\n";
Then just add $table to the remainder of the html output between the <table> and </table> tags.
Scott A. Hammond, Sr., CEO
Prima Internet, Inc.