title: COUNT of sql SELECT query with LIMIT in mySQL
body: <p>In php-mysql, how to count number of rows returned within a SELECT query?<br>
  let's think of the <code>SELECT</code> query something like this:  </p>
  
  <pre><code>$q = "SELECT * from users LIMIT 20,60"
  </code></pre>
  
  <p>But if total number of records was just for example 55, The results is users from 20 to 55 with a total number of 35 not 40!<br>
  How can I have the number 35 without querying the DB twice?<br>
  now I am doing like this:  </p>
  
  <pre><code>$q = "SELECT COUNT(*) from users LIMIT 20, 60";
  $result = mysqli_query($db_connection, $1);
  $count = mysqli_fetch_row($result);
  $count = $count[0];
  </code></pre>
  
  <p>But here I am querying the DB twice and I think this is not so good.<br>
  I know that I could have the total number of rows without considering the <code>LIMIT</code>, using <code>SQL_CALC_FOUND_ROWS</code> and <code>FOUND_ROWS()</code>, but this is not my case, as I want to consider the <code>LIMIT</code>.<br>
  Thanks!</p>