I want to echo only the first 10 rows, but I need to count the total number of rows affected by the query.
I was doing a LIMIT 10 and then counting with
It's pretty standard to issue two queries, one selecting the desired columns with the limit clause and another selecting only a count with no limit.
For example
$countQuery = 'SELECT COUNT(1) FROM Badges WHERE UID = ?';
$limitQuery = 'SELECT * FROM Badges WHERE UID = ? ORDER BY `Date` DESC LIMIT 0, 10';