fixed pagination when total page less then 5

This commit is contained in:
printempw 2016-04-03 13:06:56 +08:00
parent 37381fdf60
commit 1b1dff7863

View File

@ -37,14 +37,14 @@
'order' => 'uid',
'limit' => (string)(($page_now-1)*30).", 30"
]);
$page_total = round($db->query("SELECT * FROM ".DB_PREFIX."users WHERE `username` LIKE '%".$_POST['search-username']."%'")->num_rows/30);
$page_total = floor($db->query("SELECT * FROM ".DB_PREFIX."users WHERE `username` LIKE '%".$_POST['search-username']."%'")->num_rows/30) + 1;
} else {
$result = $db->select(null, null, [
'where' => '',
'order' => 'uid',
'limit' => (string)(($page_now-1)*30).", 30"
], null, true);
$page_total = round($db->getRecordNum()/30);
$page_total = floor($db->getRecordNum()/30) + 1;
}
while ($row = $result->fetch_array()) { ?>
@ -105,7 +105,10 @@
<?php endif;
// calculate page numbers to show
if ($page_now > $page_total - 2) {
if ($page_total < 5) {
$from = 1;
$to = $page_total;
} elseif ($page_now > $page_total - 2) {
$from = $page_total - 4;
$to = $page_total;
} elseif ($page_now > 2) {