title: How do I execute a PHP function every two seconds inside JavaScript?
body: <p>I have this PHP function called <code>GetTotalItemsPercentage()</code> which gets the amount of entries in my MySQL database and returns a percent based on the maximum amount of entries that are allowed (returns 50, 40, 39 etc.). However, I want this to update a div's height depending on this percentage. I currently have this code, however after the first update, it doesn't update again.</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          setInterval(function() {
              $("#filled-jackpot-display").animate({height:'&lt;?php include 'database/config.php'; include 'database/jackpot.php'; echo getPotFilledPercentage(); ?&gt;%'});
          }, 2000);
      &lt;/script&gt;
  </code></pre>
  
  <p>So how would I go about getting it to update every two seconds and constantly change the size of the div? I'm guessing I will have to run a loop in the PHP code and then use echo inside the PHP file to run JavaScript rather than the other way.</p>