There is no generic way to add pagination to different pages in Moodle - there is a general '$OUTPUT->paging_bar' function, which will generate the output for a paging bar, but it is then up to your own code to decide what to do with the 'page' parameter that is then passed on to the PHP script.
Usually the code looks something like this:
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 30, PARAM_INT);
...
$count = $DB->count_records_sql('Some SQL query to count the number of results');
$start = $page * $perpage;
if ($start > $count) {
$page = 0;
$start = 0;
}
$results = $DB->get_records_sql('Some SQL query to get the results', array(parameters for query), $start, $perpage); // Start at result '$start' and return '$perpage' results.
Alternatively, if this is not possible, you can get all the results and then use array_slice:
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 30, PARAM_INT);
...
$results = $DB->get_records_sql('Some SQL query to get the results', array(params for query));
$start = $page * $perpage;
if ($start > count($results)) {
$page = 0;
$start = 0;
}
$results = array_slice($results, $start, $perpage, true);