title: setInterval with php code
body: <p>I wanted to make a "friend request" option on my website and I would like if friend requests can be displayed as soon as possible. (even if I don't reload page)
  So what I've read here I need <code>setInterval</code> and Ajax, I found the code, and it works perfect for the first time, but it doesn't refresh on database changes. Is that intended or am I doing something wrong?
  Example, I have 2 friend requests, and I get one more friend request while my page is idle, and it doesn't shows up, even tho my javascript is doing the query again, right?
  I know I shouldn't use <code>mysql_query</code>, and I will fix that as soon as possible, but no way that could be the problem.</p>
  
  <pre><code>$(document).ready(function(){ 
      var ajax_call = function() {
      document.getElementById('js_hack').innerHTML = "&lt;?php 
      $ses_sql3=mysql_query("select * from friend_request where reciver='$login_username'", $connection);
      $num_rows = mysql_num_rows($ses_sql3);
      if($num_rows &gt; 0) { echo $num_rows; }?&gt;";
      };
  
      var interval = 1000 * 1; // where X is your every X minutes
  
      setInterval(ajax_call, interval);
  });
  </code></pre>