Being a newbie 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($listrow = mysql_fetch_array($listresult))
{
$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

    Sorry, just noticed some typos in my previous script. Here it comes again:

    <?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>");

    ?>

      Write a Reply...