// be moved up and down beyond the paging border
if ($totalcount > $perpage) {
$atfirstpage = ($page == 0);
- $atlastpage = (($page + 1) == ceil($totalcount / $perpage));
+ if ($perpage > 0) {
+ $atlastpage = (($page + 1) == ceil($totalcount / $perpage));
+ } else {
+ $atlastpage = true;
+ }
} else {
$atfirstpage = true;
$atlastpage = true;
$output .= ' (<a href="'. $baseurl->out(false, array($pagevar => $pagenum)).'">'. get_string('previous') .'</a>) ';
}
}
- $lastpage = ceil($totalcount / $perpage);
+ if ($perpage > 0) {
+ $lastpage = ceil($totalcount / $perpage);
+ } else {
+ $lastpage = 1;
+ }
if ($page > 15) {
$startpage = $page - 10;
if (!is_a($baseurl, 'moodle_url')){