you're on to something, you have a WHERE clause that limits the data, then a ORDER clause to order it, and then a LIMIT clause after that to take a slice.
However, there's no way to get a return that says "here's your records and Oh by the way this is page n of x".
best way to do this is,
1) strip the SELECT fields. If your query is not too complicated (doesn't use calculated fields and no "AS" aliases), you can do this:
$sql=preg_replace('/SELECT\s+[a-z0-9]+(,\s[a-z0-9]+)\s+/i','SELECT COUNT(*) ',$sql);
2) strip the limit clause as:
$sql=preg_replace('/\s+LIMIT+[0-9]+(\s,\s[0-9]+\s)$/i','',$sql);
//then run your query
$result=mysql_query($sql) or die();
$ct=mysql_fetch_array($result);
$count = $ct[0];
I refer to the limit parameters as the index and batch, respectively. Once you have the index, the batch, and the COUNT you'd have without the LIMIT clause, you have every parameter you need to figure out what the next and previous batch is, first and last batch, etc.
Hope this helps, I've been through this one already.
Sam Fullman