 <p>It's because when you have comments you print new one. What i suggest to do is use JSON to get the comments array, pass an ID to each comment and check if the Id is allready present in the list. that way you only paste new comment, here's an example.: <br> html</p> <pre><code>&lt;form action="" method="POST" id="comment-form"&gt; &lt;textarea id="home_comment" name="comment" placeholder="Write a comment..." maxlength="1000" required&gt;&lt;/textarea&gt;&lt;br&gt; &lt;input type="hidden" name="token" value="&lt;?php echo Token::generate(); ?&gt;"&gt; &lt;input id="comment-button" name="submit" type="submit" value="Post"&gt; &lt;/form&gt; &lt;div id="comment-container"&gt; &lt;div id="comment-1"&gt;bla bla bla&lt;/div&gt; &lt;/div&gt; </code></pre> <p><br> js</p> <pre><code>function commentRetrieve(){ $.ajax({ url: "ajax-php/comment-retrieve.php", type: "get", success: function (data) { // console.log(data); if (data == "Error!") { alert("Unable to retrieve comment!"); alert(data); } else { var array = JSON.parse(data); $(array).each(function($value) { if($('#comment-container').find('#comment-' + $value.id).length == 0) { $('#comment-container').prepend($value.html); } }); } }, error: function (xhr, textStatus, errorThrown) { alert(textStatus + " | " + errorThrown); console.log("error"); //otherwise error if status code is other than 200. } }); } setInterval(commentRetrieve, 300); </code></pre> <p><br> PHP</p> <pre><code>$user = new User(); $select_comments_sql = " SELECT c. *, p.user_id, p.img FROM home_comments AS c INNER JOIN (SELECT max(id) as id, user_id FROM profile_img GROUP BY user_id) PI on PI.user_id = c.user_id INNER JOIN profile_img p on PI.user_id = p.user_id and PI.id = p.id ORDER BY c.id DESC "; if ($select_comments_stmt = $con-&gt;prepare($select_comments_sql)) { //$select_comments_stmt-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $select_comments_stmt-&gt;execute(); //$select_comments_stmt-&gt;bind_result($comment_id, $comment_user_id, $comment_username, $home_comments, $comment_date, $commenter_user_id, $commenter_img); //$comment_array = array(); $rows = $select_comments_stmt-&gt;fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $comment_id = $row['id']; $comment_user_id = $row['user_id']; $comment_username = $row['username']; $home_comments = $row['comment']; $comment_date = $row['date']; $commenter_user_id = $row['user_id']; $commenter_img = $row['img']; $commenter_img = '&lt;img class="home-comment-profile-pic" src=" '.$commenter_img.'"&gt;'; if ($home_comments === NULL) { echo 'No comments found.'; } else { $html = ""; $html .= '&lt;div class="comment-post-box"&gt;'; $html .= $commenter_img; $html .= '&lt;div class="comment-post-username"&gt;'.$comment_username. '&lt;/div&gt;'; $html .= '&lt;div&gt;'.$comment_date. '&lt;/div&gt;'; $html .= '&lt;div class="comment-post-text"&gt;'.$home_comments. '&lt;/div&gt;'; $html .= '&lt;/div&gt;'; array('id' =&gt; $comment_id, 'html' =&gt; $html) } } } </code></pre> <p><br> For better improvement, i would suggest looking into NodeJs socket for more realtime update. Here's a few link.<br></p> <p><a href="https://nodejs.org/en/" rel="nofollow">Official NodeJs Website</a><br> <a href="http://socket.io/" rel="nofollow">Official SocketIo Website</a><br> <a href="http://socket.io/get-started/chat/" rel="nofollow">Chat tutorial with socketIo and Nodejs</a> <br> Hope it helps!</p> <ul> <li>Nic</li> </ul>