title: PHP str_replace in while loop
body: <p>The while function in str_replace only returns the first line of information. This is email template.</p>
  
  <pre><code>// 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."&lt;br/&gt;";
  
  }
  </code></pre>
  
  <p>The result I should have.</p>
  
  <p>Hi <strong>Jack</strong> how are you?</p>
  
  <p>Hi <strong>Mike</strong> how are you?</p>
  
  <p>Hi <strong>Alex</strong> how are you?</p>
  
  <p>But I get the wrong result:</p>
  
  <p>Hi <strong>Jack</strong> how are you? </p>
  
  <p>Hi <strong>Jack</strong> how are you? </p>
  
  <p>Hi <strong>Jack</strong> how are you?</p>
  
  <hr>
  
  <p>If I do not use the str_replace function it works correctly.</p>
  
  <p><strong>How do I use the str_replace function in while loop?
  Thank you.</strong></p>