Re: [PHP3] Capturning output from mysql loop
| From: | (Richard Lynch) | Date: | Fri, 09 Jun 2000 23:10:09 +0000 |
| Subject: | Re: [PHP3] Capturning output from mysql loop | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1491@lists.php.net to get a copy of this message | ||
In article <000701bfd043$e2dec620$be90fea9@kl>, k@bigsky.net ("Kevin
Leavell") wrote:
> I query a mysql database and pull up a variable amount of records. To
> capture the information from the records, I output the loop into a
> <textarea> box. I then press submit which sends all the data to as a single
> variable to the email section of the script. This actually works well but
> is extremely cheesy. Below is an outline of what I am doing. I want to get
> rid of the textbox stuff. I want to loop through the info a send it with no
> user intervention.
<?php
$query = 'select name, fruit from fruits';
$prefs = mysql_query($query);
$mailbody = '';
while (list($name, $fruit) = mysql_fetch_row($prefs)){
$mailbody .= "$name likes $fruit\r\n";
}
$mail = mail('applecensusbureau@apple.com', 'Cencus', $mailbody, "From:
k@bigsky.net\r\nReply-to: k@bigsky.net\r\n");
if (!$mail){
echo "Cencus failed.";
}
else{
echo "Thank you.";
}
?>
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)