The while function in str_replace only returns the first line of information. This is email template.
// I have a macro in my message. (member name)
$message = "Hi {%write_member_name%} how are you?";
$connect = mysql_query("SELECT * FROM members");
while($row=mysql_fetch_array($connect)){
$membername = $row["member_name"];
$message = str_replace('{%write_member_name%}', $membername ,$message);
echo $message."<br/>";
}
The result I should have.
Hi Jack how are you?
Hi Mike how are you?
Hi Alex how are you?
But I get the wrong result:
Hi Jack how are you?
Hi Jack how are you?
Hi Jack how are you?
If I do not use the str_replace function it works correctly.
How do I use the str_replace function in while loop? Thank you.
$row["member_name"]? Is it also printing the same value all the time?