title: Comment notification for a social site
body: <p>I'm creating a social networking site where users can chat to eachother, They also can post and comment on them but problem is occured when i am tried to send comment notifications to the users whose commented on post and post_author i have tried many times with different coding experience but i failed</p>
  
  <p>This is local server running MySql ,PHP,and Apache </p>
  
  <p><a href="https://i.stack.imgur.com/fpXhs.png" rel="nofollow noreferrer">This is image</a>
  You Can see in the above image , There are 3 ids <code>post_id</code> on which post commented,<code>user_id</code> who has commented on the post and <code>author_id</code> this is <code>post_author id</code>, actually i want when <code>post_author</code> commented which is having <code>author_id = 3</code> then all the users who has commented on the particular post for example <code>user_id= 1 and 2</code> whose commented on <code>post_id = 58</code> should be notified except <code>user_id = 3</code>, and when <code>user_id = 2</code> commented on the same post then <code>author_id = 3</code> and <code>user_id = 1</code> should be notified1 i hope you understand what i want. Here is the code what i have tried.</p>
  
  <pre><code>$q = mysqli_query($con,"SELECT * FROM comments WHERE user_id = '$_SESSION['user_id']' ORDER BY com_id");
  
  if(mysqli_num_rows($q) &gt; 0){
  $notis = mysqli_fetch_all($q, MYSQLI_ASSOC)
  foreach($notis as $noti){
  $q2 = "SELECT * FROM users WHERE user_id="'.$noti['user_id'].'""
  $fetch = mysqli_fetch_array($q2);
  $nick = $fetch['user_nick'];
  }}
  </code></pre>
  
  <p>for example <code>$nick(John)Commented on your post</code>
  And when another user commented on the same post for example <code>$nick(smith)commented on your post</code>
  This code notify the post_author</p>
  
  <p>i want to create notification chain for example when a user commented on a post then notify the post_author and also notify all users whose has commented on that post firstly.. and when post_author commented on his post then notify the all users whose commented on post..</p>
  
  <p>if i try to send notifications to the users who has commented on a particular post </p>
  
  <pre><code>$q = mysqli_query($con,"SELECT * FROM comments WHERE user_id != '$_SESSION['user_id']' ORDER BY com_id");`
  
  if(mysqli_num_rows($q) &gt; 0){
  $notis = mysqli_fetch_all($q, MYSQLI_ASSOC)
  foreach($notis as $noti){
  $q2 = "SELECT * FROM users WHERE user_id="'.$noti['user_id'].'""
  $fetch = mysqli_fetch_array($q2);
  $nick = $fetch['user_nick'];
  }}
  </code></pre>
  
  <p>for example <code>$nick(John)Commented on his post</code>
  this code notify all the users in the database except post_author </p>
  
  <p>please help to create a proper comment notification what should be i do...</p>