Re: Can this be done with mail()?
| From: | Richard Lynch | Date: | Sun, 14 Jul 2002 06:09:30 +0000 |
| Subject: | Re: Can this be done with mail()? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-107581@lists.php.net to get a copy of this message | ||
>
>I need to query a database and return a resultset. A php script will then
>sort through the data and send the data to the browser in the form of a table.
>
>Is it possible to gather the the results with html tags and store them in a
>variable so that the results can be emailed to someone? If so, how would
>this be done?
Do as much of the sorting/searching in SQL as you can. MUCH faster.
Use the mail class from http://phpclasses.org to do the
html-enhanced email.
WARNING: Many readers will simply *TRASH* your "enhanced" email. Re-think
your priorities.
Collecting your HTML in a variable is easy:
<?php
$html = '';
# Get db stuff
$html .= "<TABLE>\n";
# Loop through results{
$html .=
"<TR><TD>$x</TD><TD>$y</TD><TD>$z</TD></TR>\n";
}
$html .= "</TABLE>\n";
?>
It's just like doing everything with "echo", only not. :-)
You may want to echo some stuff out as well, so you know what's happening...
--
Like Music? http://l-i-e.com/artists.htm