title: Issue with pagination
body: <p>I'm making a simple select-from-database-and-display application and am building pagination to go alongside it.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php   
     $sqlcount = "SELECT * FROM user where user_id= ?";
     $qcount = $db-&gt;prepare($sqlcount);
     $qcount-&gt;execute(array($id));
     $qcount-&gt;setFetchMode(PDO::FETCH_BOTH);
     $total = $qcount-&gt;rowCount();
  
     // How many items to list per page
     $limit = 10;
  
     // How many pages will there be
     $pages = ceil($total / $limit);
  
     // What page are we currently on?
     $page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array(
                              'options' =&gt; array(
                                  'default'   =&gt; 1,
                                  'min_range' =&gt; 1,
                              ),
     )));
  
     // Calculate the offset for the query
     $offset = ($page - 1)  * $limit;
  
     // Some information to display to the user
     $start = $offset + 1;
     $end = min(($offset + $limit), $total);
  
     // The "back" link
     $prevlink = ($page &gt; 1) ? '&lt;a href="?page=1" title="First page"&gt;&amp;laquo;&lt;/a&gt; &lt;a href="?page=' . ($page - 1) . '" title="Previous page"&gt;&amp;lsaquo;&lt;/a&gt;' : '&lt;span class="disabled"&gt;&amp;laquo;&lt;/span&gt; &lt;span class="disabled"&gt;&amp;lsaquo;&lt;/span&gt;';
  
     // The "forward" link
     $nextlink = ($page &lt; $pages) ? '&lt;a href="?page=' . ($page + 1) . '" title="Next page"&gt;&amp;rsaquo;&lt;/a&gt; &lt;a href="?page=' . $pages . '" title="Last page"&gt;&amp;raquo;&lt;/a&gt;' : '&lt;span class="disabled"&gt;&amp;rsaquo;&lt;/span&gt; &lt;span class="disabled"&gt;&amp;raquo;&lt;/span&gt;';
  
     // Display the paging information
     echo '&lt;div id="paging"&gt;&lt;p&gt;', $prevlink, ' Page ', $page, ' of ', $pages, ' pages, displaying ', $start, '-', $end, ' of ', $total, ' results ', $nextlink, ' &lt;/p&gt;&lt;/div&gt;';
  
     $stmt = $db-&gt;prepare("SELECT * FROM recipes WHERE user_id = :userid ORDER BY name LIMIT :limit OFFSET :offset");
     $stmt-&gt;bindParam(':userid', $id, PDO:: PARAM_INT);
     $stmt-&gt;bindParam(':limit', $limit, PDO:: PARAM_INT);
     $stmt-&gt;bindParam(':offset', $offset, PDO:: PARAM_INT);
     $stmt-&gt;execute();
     $rowcount = $stmt-&gt;rowCount();
  
     echo "&lt;ul id='container'&gt;";
     if(empty($rowcount)){echo"No recipes";}
     while($row = $stmt-&gt;fetch()){
      $recipeid = $row['id'];
      $public = $row['public'];
  
      //here i left out some stuff unimportant to the problem
     }
  ?&gt;
  </code></pre>
  
  <p>Before I put in the pagination, my results were displayed. Now, with error reporting on there are no errors, but it displays "No Recipes" and <code>« ‹ Page 0 of 0 pages, displaying -9-0 of 0 results › »</code>.</p>