Try something like:

<?php

$listquery = "SELECT emailaddress FROM subscribers";
$listresult = mysql_query($listquery);
$newsquery = "SELECT * FROM newsarticles";
$newsresult = mysql_query($newsquery);

while($listrow = mysql_fetch_array($listresult))  {
    $newsrow = mysql_fetch_array($newsresult))
    $message = $newsrow[article];
 
    $recipient = $listrow[emailaddress];
    $subject = "Welcome to my ezine";
    $mailheaders = "From: [EMAIL PROTECTED]\n";
    $mailheaders .= "Reply-To: [EMAIL PROTECTED]";

    mail($recipient, $subject, $message, $mailheaders);
} 

echo ("The message has been sent</p>");

?> 

if it works, which it should, and you would like to know why, please email
me and Ill explain it ;)


> 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: [EMAIL PROTECTED]\n";
> $mailheaders .= "Reply-To: [EMAIL PROTECTED]";
> 
> 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
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to