title: How to get results from query using loop
body: <p>I'm trying to make a query using procedural PHP. I've used OOP mostly. It's not giving correct results.
  I want to get all records from table offers and then make an array width all offer ids in it.</p>
  
  <p>When <code>print_r($sql-&gt;getNumRows())</code> - it gives me correct count. But I want to put ids in array and when I <code>print_r(count($all))</code>  - count is bigger.</p>
  
  <p>What is proper way to do that? </p>
  
  <p>My code is:</p>
  
  <pre><code>$sql-&gt;query("SELECT id  FROM offers ORDER BY id ASC");
  if ($row=$sql-&gt;getNumRows()) {
      for ($i=0; $i&lt; $sql-&gt;getNumRows(); $i++) { 
          $all[]= $sql-&gt;getRow($i);
      }
  
      print_r($sql-&gt;getNumRows()); //this prints correct number
      print_r(count($all)); //this prints bigger count
  </code></pre>