Forum Moderators: coopster
Here is my code:
query database stuff.....
while ($row = mysql_fetch_array($result))
{
$subname[] = $row['listname'];
$subemail[] = $row['listemail'];
}for ($i=0; $i<sizeof($subname); $i++)
{
$mailcomments = eregi_replace("<--subname-->", $subname[$i], $mailcomments);
$mailcomments = eregi_replace("<--unsub-->", $website_url . "/mail.php?action=unsubscribe&email=" . $subemail[$i], $mailcomments);
$mailcomments = stripslashes($mailcomments);
mail($subemail[$i], $mailsubject, $mailcomments, "From: $website<$webemail>");}
messageSent();
The e-mails are looping ok, but the name that is displayed in the e-mails and the unsubscribe e-mail are always the first person in the database. So the eregi_replace parts aren`t looping.
I assume I`m just missing something silly like a [$i]?
Thanks for the help!
:)
$mailcomments_copy = $mailcomments; //make copy of original string
for ($i=0; $i<sizeof($subname); $i++)
{
$mailcomments_copy = eregi_replace("<--subname-->", $subname[$i], $mailcomments_copy);
$mailcomments_copy = eregi_replace("<--unsub-->", $website_url . "/mail.php?action=unsubscribe&email=" . $subemail[$i], $mailcomments_copy);
$mailcomments_copy = stripslashes($mailcomments_copy);
mail($subemail[$i], $mailsubject, $mailcomments_copy, "From: $website<$webemail>");}
This should work.
Jaski
query database stuff.....while ($row = mysql_fetch_array($result))
{
$subname[] = $row['listname'];
$subemail[] = $row['listemail'];}
$mailcomments_copy = $mailcomments; //make copy of original string
for ($i=0; $i<sizeof($subname); $i++)
{
$mailcomments = eregi_replace("<--subname-->", $subname[$i], $mailcomments);
$mailcomments = eregi_replace("<--unsub-->", $website_url . "/mail.php?action=unsubscribe&email=" . $subemail[$i], $mailcomments);
$mailcomments = stripslashes($mailcomments);
mail($subemail[$i], $mailsubject, $mailcomments, "From: $website<$webemail>");$mailcomments = stripslashes($mailcomments_copy);
}messageSent();