[eluser]kgill[/eluser]
You're going to have to make two queries if you're using limit, you're asking the database to provide you with two entirely different things. One, X number of users (specified by your per page) and two, the total number your query would return if you didn't apply a limit. Although, for the second query you don't need to to re-run the entire thing again, a couple simple modifications will make your life easier.
Add this to your first query: SQL_CALC_FOUND_ROWS
So you've got: select SQL_CALC_FOUND_ROWS * from ...
For the second query, just replace it with a call the MySQL function: FOUND_ROWS()
So: select FOUND_ROWS();
If found_rows doesn't work then you'll have to use a select count(*), there's no need to do it in a two step process of rerunning the query and then doing a num_rows when you can grab it in one.
- K