email newsletter with MySQL - help please!

From: Date: Mon, 13 Aug 2001 12:53:53 +0000
Subject: email newsletter with MySQL - help please!
Groups: php.general 
Request: Send a blank email to php-general+get-62413@lists.php.net to get a copy of this message
Being a rather new to php I find myself completely stuck on a script which is possibly a piece of cake for most of you: I want to set up a weekly ezine. Both email addresses and news articles will be retrieved from two separate MySQL tables called "subscribers" and "newsarticles". I put together the following script but it doesn't work the way I want it to: <?php $listquery = "SELECT emailaddress FROM subscribers"; $listresult = mysql_query($listquery); while($listrow = mysql_fetch_array($listresult)) { $newsquery = "SELECT * FROM newsarticles"; $newsresult = mysql_query($newsquery); while($newsrow = mysql_fetch_array($newsresult)) { $message = $newsrow[article]; } $recipient = $listrow[emailaddress]; $subject = "Welcome to my ezine"; $mailheaders = "From: Herman.Pijpers@infonomics.nl\n"; $mailheaders .= "Reply-To: herman.pijpers@infonomics.nl"; mail($recipient, $subject, $message, $mailheaders); } echo ("The message has been sent</p>"); ?> That's it. A message IS being sent to all subscribers, but somehow, this message only contains the latest newsarticle in the database in stead of the whole array. What am I doing wrong? Any help in this will be greatly appreciated! Best, Herman

« previous php.general (#62413) next »