title: How to run multiple queries in one php page?
body: <p>I have a select query and then another select query but for another table. I need to run the first query, then if it finds something, show a table with a foreach loop. And then, a second query run and select another table with a foreach loop too.</p>
  
  <p>This is my DB class to run my DB :</p>
  
  <pre><code>class DB {
  private static $_instance = null;
  private $_pdo, 
          $_query, 
          $_error = false,
          $_count = 0;
  public $_results;
  
  private function __construct() {
      try {
          $this-&gt;_pdo = new PDO(...);
      } catch(PDOException $e) {
          die($e-&gt;getMessage());
      }
  }
  
  public static function getInstance() {
      if(!isset(self::$_instance)) {
          self::$_instance = new DB();
      }
      return self::$_instance;
  }
  
  public function query($sql, $params = array()) {
      $this-&gt;_error = false;
      if($this-&gt;_query = $this-&gt;_pdo-&gt;prepare($sql)) {
          $x = 1;
           if(count($params)) {
              foreach($params as $param) {
                  $this-&gt;_query-&gt;bindValue($x, $param);
                  $x++;
              }
          }
          if($this-&gt;_query-&gt;execute()) {
              $this-&gt;_results = $this-&gt;_query-&gt;fetchAll(PDO::FETCH_OBJ);
              $this-&gt;_count = $this-&gt;_query-&gt;rowCount();
          } else {
              $this-&gt;_error = true;
          }
      }
  
      return $this;
  }
  </code></pre>
  
  <p>Then, on a page I have this following :</p>
  
  <pre><code>&lt;?php if ($st = DB::getInstance()-&gt;query("SELECT * FROM resum WHERE form_id = ? ORDER by date DESC", array(Input::get('formID')))) {
          if ($st-&gt;count()) { ?&gt;
  
              &lt;div id="topSeparateurClient"&gt;
              &lt;div&gt;Date&lt;/div&gt;
              &lt;div&gt;Concessionnaire&lt;/div&gt;
              &lt;div&gt;Client&lt;/div&gt;
              &lt;div&gt;Voiture&lt;/div&gt;
              &lt;div&gt;Prix&lt;/div&gt;
              &lt;div&gt;Statut&lt;/div&gt;
          &lt;/div&gt;
          &lt;div style="clear:both;"&gt;&lt;/div&gt;
  &lt;?php
              foreach($st-&gt;_results as $result) {
                  echo "&lt;div class=\"clientGenInfos\"&gt;
                          &lt;div&gt;&lt;b&gt;".substr($result-&gt;date, 0, 10)."&lt;/b&gt; / ".substr($result-&gt;date, 10)."&lt;/div&gt;
                          &lt;div&gt;".$result-&gt;concessionnaire."&lt;/div&gt;
                          &lt;div&gt;".$result-&gt;client."&lt;/div&gt;
                          &lt;div&gt;".$result-&gt;voiture."&lt;/div&gt;
                          &lt;div&gt;".$result-&gt;prix."&lt;/div&gt;";
  
                          if ($result-&gt;statut == 'En Attente') {
                              echo '&lt;div class="enAttente"&gt;&lt;span&gt;En Attente&lt;/span&gt;&lt;/div&gt;';
                          } else if ($result-&gt;statut == 'Accepter') {
                              echo '&lt;div class="accepter"&gt;&lt;span&gt;Accepter&lt;/span&gt;&lt;/div&gt;';
                          } else if ($result-&gt;statut == 'Refuser') {
                              echo '&lt;div class="refuser"&gt;&lt;span&gt;Refuser&lt;/span&gt;&lt;/div&gt;';
                          }
  
                  echo "  &lt;/div&gt;
                  ";
              }
  
          } else {
              echo '&lt;div class="aucuneDemande"&gt;Nothing from now.&lt;/div&gt;';
          }
  
      }
   ?&gt;
  </code></pre>
  
  <p>Then a second block, almost identical but with another table name in his query. The problem now is that my second table have the same values as the first one..I am stuck here, reading stuff on the net and nothing about this situation. I am still new to PDO object! please help!</p>
  
  <p>EDIT ---</p>
  
  <p>This is my second block..</p>
  
  <pre><code>    &lt;?php 
      if ($st = DB::getInstance()-&gt;query("SELECT * FROM users WHERE users.group = 3 ORDER by date DESC")) {
          if ($st-&gt;count()) { ?&gt;
  
              &lt;div id="topSeparateurClientConc"&gt;
              &lt;div&gt;Pr&amp;eacute;nom et Nom&lt;/div&gt;
              &lt;div&gt;Adresse&lt;/div&gt;
              &lt;div&gt;Nom d'utilisateur&lt;/div&gt;
              &lt;div&gt;Date d'inscription&lt;/div&gt;
              &lt;div&gt;Demandes re&amp;ccedil;ues&lt;/div&gt;
          &lt;/div&gt;
          &lt;div style="clear:both;"&gt;&lt;/div&gt;
  &lt;?php
              foreach($st-&gt;_results as $result2) {
                  echo "&lt;div class=\"clientGenInfosConc\"&gt;
                          &lt;div&gt;".$result2-&gt;name."&lt;/div&gt;
                          &lt;div&gt;".$result2-&gt;adresse."&lt;/div&gt;
                          &lt;div&gt;".$result2-&gt;username."&lt;/div&gt;
                          &lt;div&gt;&lt;b&gt;".substr($result2-&gt;joined, 0, 10)."&lt;/b&gt; / ".substr($result2-&gt;joined, 10)."&lt;/div&gt;
                          &lt;div&gt;".$result2-&gt;concessionnaire."&lt;/div&gt;
                      &lt;/div&gt;";
              }
          } else {
              echo '&lt;div class="aucuneDemande"&gt;Aucune demande transf&amp;eacute;rable en ce moment&lt;/div&gt;';
          }
      }
   ?&gt;
  </code></pre>