title: how to auto refresh multiple php variables without refreshing page? I can only do one atm
body: <p>I'm trying to auto-refresh multiple PHP variables. So far I can only auto-refresh one variable and the rest do not work (it will always be the last one that works, so <code>var2</code>).</p>
  
  <p>I was thinking of making a JSON script and trying to do it like that but how would I go about making each array in the JSON to auto-refresh on my PHP page without refreshing the whole page?</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;script language="javascript" src="jquery-1.2.6.min.js"&gt;&lt;/script&gt;
  &lt;script language="javascript" src="jquery.timer-1.0.0.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="css/bootstrap.css"&gt;
  &lt;link rel="stylesheet" href="css/bootstrap.min.css"&gt;
  
  &lt;script src="jquery-1.9.0.min.js"&gt;&lt;/script&gt;
  &lt;?php $ra = "&lt;div id='c1b'&gt;&lt;/div&gt;
  
      &lt;script type='text/javascript'&gt;
      $(document).ready(function() {
          $('#c1b').load('var1.php');
          refresh();    
      });
      function refresh(){
          setTimeout( function() {
              $('#c1b').fadeOut('slow').load('var1.php').fadeIn('slow');
              refresh();  
          }, 2000);
      }
      &lt;/script&gt;";
  $rb = "&lt;div id='c2b'&gt;&lt;/div&gt;
          &lt;script type='text/javascript'&gt;
          $(document).ready(function() {
              $('#c2b').load('var2.php');
              refresh();    
          });
          function refresh(){
              setTimeout( function() {
                  $('#c2b').fadeOut('slow').load('var2.php').fadeIn('slow');
                  refresh();  
              }, 2000);
          }
          &lt;/script&gt;"; ?&gt;
  
  &lt;?php echo $ra . ' &amp; ' . $rb ?&gt;
  </code></pre>
  
  <p>var1.php</p>
  
  <pre><code>&lt;?php 
  include_once 'connect.php';
  $d= 'var1';
  $q = $handler-&gt;prepare("SELECT * FROM var WHERE name = ?");
  $q-&gt;bindParam(1, $d);
  $q-&gt;execute();
  while($r = $q-&gt;fetch()){
      $e = $r['names'];   
  }
  echo $e;
  ?&gt;
  </code></pre>
  
  <p>var2.php</p>
  
  <pre><code>&lt;?php 
  include_once 'connect.php';
  $d= 'var2';
  $q = $handler-&gt;prepare("SELECT * FROM var WHERE name = ?");
  $q-&gt;bindParam(1, $d);
  $q-&gt;execute();
  while($r = $q-&gt;fetch()){
      $e = $r['names'];   
  }
  echo $e;
  ?&gt;
  </code></pre>