title: Combine requests for multiple PHP files to one request
body: <p>I have a dynamic web dashboard which displays data like temp, humidity, light, noise etc. I have multiple php files like temp.php, humidity.php, light.php and noise.php which take care of retrieving the data from db and then I have multiple js files too which basically use setTimeout and displays data from the corresponding php file to the html page every 3 seconds. </p>
  
  <p>Each of the php file looks like this, example- humidity.php:</p>
  
  <pre><code>    &lt;?php
      session_start();
      if(isset($_SESSION["user_id"])){
      include('db.php');
      $unit = "820";
      $stmt = $db-&gt;prepare("SELECT hv FROM humidity where 
  unitid=? order BY pk DESC LIMIT 1");
      $stmt-&gt;execute([$unit]);
      $humidity= $stmt-&gt;fetchColumn();
      $humidity=round($humidity, 2, PHP_ROUND_HALF_ODD);
      echo $humidity;
      $stmt-&gt;closeCursor();
      $db = null;
      }
      ?&gt; 
  </code></pre>
  
  <p>And each js file looks like this, example- humidity.js:</p>
  
  <pre><code>$(document).ready(function() {
          function foo() {
              $('#showhumidity').load('humidity.php');
  
              setTimeout(foo, 3000);
          }
  
      foo();
  
  
      });
  </code></pre>
  
  <p>The process is working fine, but since there are multiple php requests, the overall processing time is little high (around 2 seconds). I would like to combine the phps into one php file and the js files into one too - thereby having just one php request to retrieve all the data. </p>
  
  <p>What is the best way to do it? </p>