Update paginate.php

This commit is contained in:
Namhyeon Go 2018-07-01 16:12:40 +09:00 committed by GitHub
parent 124ee96bd6
commit a5d90cc6a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,12 +4,23 @@
* @date 2018-01-01 * @date 2018-01-01
* @author Go Namhyeon <gnh1201@gmail.com> * @author Go Namhyeon <gnh1201@gmail.com>
* @brief Page navigation helper * @brief Page navigation helper
* @original-author Saran (Sanwebe)
* @original-article-url https://www.sanwebe.com/2011/05/php-pagination-function
*/ */
if(!function_exists("make_paginate")) { if(!function_exists("paginate_get_total_pages")) {
function make_paginate($item_per_page, $current_page, $total_records, $total_pages, $page_url, $qry='') { function paginate_get_total_pages($item_per_page=1.0, $total_records=1.0) {
$total_pages = 1;
if($item_per_page > 0) {
$total_pages = ceil($total_records / $item_per_page);
}
return $total_pages;
}
}
// https://www.sanwebe.com/2011/05/php-pagination-function
if(!function_exists("paginate_make_html")) {
function paginate_make_html($item_per_page, $current_page, $total_records, $total_pages, $page_url, $qry='') {
$pagination = ''; $pagination = '';
if($total_pages > 0 && $total_pages != 1 && $current_page <= $total_pages) { //verify total pages and current page number if($total_pages > 0 && $total_pages != 1 && $current_page <= $total_pages) { //verify total pages and current page number
$pagination .= '<ul class="pagination justify-content-end">'; $pagination .= '<ul class="pagination justify-content-end">';