Thanks to Anthony's advice I've tried to simplify my logic and syntax of the goal I am trying to achieve which is when a blog is written, the AUTHOR gets notified by php mail that someone other than himself comments. When the AUTHOR comments everyone else who commented except him gets a different email. When another user comments, the AUTHOR gets notified as stated above, but everyone else who has commented gets an email, the same one that the AUTHOR sends OUT when he comments on his OWN blog and yes I'm STILL a newbie:
if(isset($_POST['commentBlogSubmit']) && $auth) {
$query = "SELECT `Email` FROM `Users` WHERE `id` = '" . $prof->id . "'";
$request = mysql_query($query,$connection) or die(mysql_error());
$result = mysql_fetch_array($request);
$Email = $result['Email'];
$to = $Email;
$subject = "$auth->first_name $auth->last_name left you a blog comment";
$message = "$auth->first_name $auth->last_name left you new blog comment:<br /> <br /> <a href='BlogProfile.php?id=" . $blog->id . "'>Click here to view</a><br /><br />";
$from = "<[email protected]>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:$from";
mail($to, $subject, $message, $headers);
if($blog->author != $poster->id) {
$query = "SELECT * FROM `BlogComments` WHERE `blogID` = '" .$blog->id. "'";
$request = mysql_query($query,$connection);
while($result = mysql_fetch_array($request)) {
$emailPoster = ($result['userID']);
$to = $emailPoster;
$subject = "$auth->first_name $auth->last_name Commented";
$message = "$auth->first_name $auth->last_name commented on the blog $blog->title :<br /> <br /> <a href='BlogProfile.php?id=" . $blog->id . "'>Click here to view</a><br /><br />";
$from = "<[email protected]>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:$from";
mail($to, $subject, $message, $headers);
}