title: convert to array from database sql php
body: <pre><code>&lt;?php   
  $content = "my content";
  $parts = array("Part 1 :", "Part 2 :", "Part 3 :","Part 4 :", "Part 5 :");
  $name_list = array("Part 1 :\n", "Part 2 :\n", "Part 3 :\n","Part 4 :\n", "Part 5 :");
  
  $email_body = "Product:\n" .str_replace($parts, $name_list, $content);
  ?&gt;
  </code></pre>
  
  <p>How I can obtain the same result as in the first script, but I want to import the second array <code>$name_list</code> from my database.</p>
  
  <p>I did the script below, but it doesn't work.</p>
  
  <pre><code>&lt;?php 
  $query  = "SELECT * FROM my_table WHERE  id LIKE '%$id%'";
  $search = mysql_query($query ) or die(mysql_error());
  
  $name_list = array();
  while ($row = mysql_fetch_array($search)) {
      $name_list[] = $row['name'] . ":\n,";
  }
  $name_list = explode(", ", $name_list);
  ?&gt;
  </code></pre>