title: Auto-refresh PHP display variable
body: <p>I am needing to automatically refresh my PHP page. I have a PHP page that is returning the current database time. However, this is requiring me to refresh the page in order for me to update.I need a better way of updating this PHP variable that does not include refreshing the page. Here's what I have so far:</p>
  
  <pre><code>$time = current_time($db);
  echo '&lt;p&gt;$time&lt;/p&gt;'
  </code></pre>
  
  <p>How can I accomplish this?
  EDIT:
  I've changed my code but it still won't auto-refresh:
  index.php</p>
  
  <pre><code>&lt;div id="#timeLocation"&gt;
  
  &lt;script&gt;
  var updateTime = function(){
  $.ajax({url: "time.php", success: function(response){
  $('#timeLocation').html(response);
  }});
  setInterval(updateTime, 1000);
  }
  
  updateTime();
  
  &lt;/script&gt;
  
  
  &lt;/div&gt;
  </code></pre>
  
  <p>time.php</p>
  
  <pre><code> &lt;?php 
  
   require_once('db.php');
   require_once('functions.php');
  
  $time = current_time($db);
  echo $time[0];
  
  
  ?&gt;
  </code></pre>