title: How can I get phpmail to send to the right user and also limit the ammount of emails for certain users? Part 2
body: <p>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:</p>
  
  <pre><code>if(isset($_POST['commentBlogSubmit']) &amp;&amp; $auth) {
  
  
  
          $query = "SELECT `Email` FROM `Users` WHERE `id` = '" . $prof-&gt;id . "'";
          $request = mysql_query($query,$connection) or die(mysql_error());
          $result = mysql_fetch_array($request); 
  
          $Email = $result['Email'];
  
  
          $to = $Email;
          $subject = "$auth-&gt;first_name $auth-&gt;last_name left you a blog comment";
          $message = "$auth-&gt;first_name $auth-&gt;last_name left you new blog comment:&lt;br /&gt; &lt;br /&gt; &lt;a href='BlogProfile.php?id=" . $blog-&gt;id . "'&gt;Click here to view&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;";
              $from = "&lt;noreply@site.com&gt;";
          $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-&gt;author != $poster-&gt;id) { 
  
          $query = "SELECT * FROM `BlogComments` WHERE `blogID` = '" .$blog-&gt;id. "'";
          $request = mysql_query($query,$connection);
          while($result = mysql_fetch_array($request)) { 
  
          $emailPoster = ($result['userID']);
  
              $to = $emailPoster;
              $subject = "$auth-&gt;first_name $auth-&gt;last_name Commented";
              $message = "$auth-&gt;first_name $auth-&gt;last_name commented on the blog $blog-&gt;title :&lt;br /&gt; &lt;br /&gt; &lt;a href='BlogProfile.php?id=" . $blog-&gt;id . "'&gt;Click here to view&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;";
  
              $from = "&lt;noprely@site.com&gt;";
              $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);
  
  
  
  
          }
  </code></pre>