Use SQL_CALC_FOUND_ROWS in your SELECT query and then run SELECT FOUND_ROWS() after that:
SQL_CALC_FOUND_ROWS
SELECT FOUND_ROWS() after that
SELECT SQL_CALC_FOUND_ROWS field_name,filed_name2 FROM tables WHERE CLAUSE LIMIT X; SELECT FOUND_ROWS() ;