title: How to get all rows from myslq table by foreach loop in php pdo
body: <p>I am trying to collect all rows from a table of mySql database. But I am getting 1 row lesser than the original rows. Suppose the table has 3 rows but I am getting data of 2 rows. I am missing the first one always. Here is the image of my table. </p>
  
  <p><a href="https://i.stack.imgur.com/MibxS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MibxS.png" alt=""></a></p>
  
  <p>Here is my code: </p>
  
  <pre><code>$query = $db-&gt;query("SELECT * FROM `POS_refund`");
  
  if($query-&gt;fetchColumn() &gt; 0){
  
       foreach($query as $row){
  
          echo $get_prod_id = $row['prod_id'];
  
          $get_prod_qnt = $row['qnt'];
  
      } 
  
  }
  </code></pre>
  
  <p>Where is the fault? </p>