Since Reza Mamun offers his solution, it works fantastically ... I also want to create a SELECT HTML element for navigating between pages. This requires a slightly different approach.
To create a SELECT element, I use an array with the keys 'name' and 'value', so the SQL query looks like this:
$qry=' SELECT d.RowNumber, FLOOR( ( d.RowNumber ) / %s ) AS value, d.name FROM( SELECT %s AS ID, %s AS name, @rownum: =@rownum +1 AS RowNumber FROM %s, ( SELECT @rownum:=-1 ) AS Initialize %s %s ) AS d WHERE d.Rownumber MOD %s = 0'; $sqry = sprintf( $qry, $pagelength, $this->_tableindex, $sort_field, $this->_tablename, $cond, $sql_order, $pagelength );
The query works with filtering by WHERE (user-defined through the form), ORDER BY sorting (selected by used). I think the meaning of variables and properties can be distinguished. This solution is designed for (almost) universal pagination and user-defined page lengths.
source share