I can't find a way to edit my post, but would this work for you?
private _addresses;
public function insert_NewsCast($topic, $content) {
$query = $this->db->prepare("INSERT INTO `news` (`topic`, `content`, `date`) VALUES (?, ?, NOW())");
$query->bindValue(1, $topic);
$query->bindValue(2, $content);
try {
$query->execute();
$query = $this->db->prepare('SELECT `address` from `emails`');
try {
$query->execute();
$result = $query->fetchAll();
foreach($result as $row) {
$addresses = (empty($addresses)) ? $row['email'] : $addresses .= ', ' . $row['address'];
}
}
catch (PDOException $e) {
die($e->getMessage());
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = '<html>' .
'<head>' .
' <title>Notification from test site</title>' .
'</head>' .
'<body>' .
' <p>New post up on the Website!</p>' .
' <a href = "http://www.test.co.za">Take a look</a>' .
' <p>Regards,<br />The Team!</p>' .
'</body>' .
'</html>';
mail($addresses, $topic, $message, $headers);
}
}