<?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);
?>
How I can obtain the same result as in the first script, but I want to import the second array $name_list from my database.
I did the script below, but it doesn't work.
<?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);
?>