mysql - Find page of result record in pagination

First get total number of records.

select count(*) as total from members; 

Find the number of the row member 'x' is found in the record list

select count(*) oneLess from members where id < (select id from members where name='x');

The above query returns oneLess the record number from x. i.e. 'x' is oneLess+1

Now calculate the page number.

$asc_page_no =  floor((($oneLess+1)/$total)*$len);
$total_pages = floor($total/$len);
$page_no = $total_pages - $asc_page_no; //reverse the page looking direction

Then calculate $start

$start = $page_no * $len;