Home PHP Libraries Pagination library php-paginator paging processing class
php-paginator paging processing class
<?php
namespace JasonGrimes;
class Paginator
{
    const NUM_PLACEHOLDER = '(:num)';
    protected $totalItems;
    protected $numPages;
    protected $itemsPerPage;
    protected $currentPage;
    protected $urlPattern;
    protected $maxPagesToShow = 10;
    protected $previousText = 'Previous';
    protected $nextText = 'Next';
    /**
     * @param int $totalItems The total number of items.
     * @param int $itemsPerPage The number of items per page.
     * @param int $currentPage The current page number.
     * @param string $urlPattern A URL for each page, with (:num) as a placeholder for the page number. Ex. '/foo/page/(:num)'
     */
    public function __construct($totalItems, $itemsPerPage, $currentPage, $urlPattern = '')
    {
        $this->totalItems = $totalItems;
        $this->itemsPerPage = $itemsPerPage;
        $this->currentPage = $currentPage;
        $this->urlPattern = $urlPattern;
        $this->updateNumPages();
    }

Function 1: Generate paging navigation and paging function parameter list based on the total number of pages, current page, page grouping and url (how many pages, current page, how many per page, link address). Function 2: According to the number of records, page columns are counted, $page, current page; $row_num total number of records; $pagesize: number of records per page; $url record page.

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP uses the Mysqli class library to achieve perfect paging effect, mysqli class library_PHP tutorial PHP uses the Mysqli class library to achieve perfect paging effect, mysqli class library_PHP tutorial

12 Jul 2016

PHP uses the Mysqli class library to achieve perfect paging effects, the mysqli class library. How PHP uses the Mysqli class library to achieve perfect paging effects, mysqli class library This article describes how PHP uses the Mysqli class library to achieve perfect paging effects. Share it with everyone for your reference.

Simple, convenient, full-featured PHP paging class Simple, convenient, full-featured PHP paging class

09 Jul 2016

Simple, convenient, full-featured PHP paging class,

Simple paging class and usage examples implemented in PHP, php paging usage examples_PHP tutorial Simple paging class and usage examples implemented in PHP, php paging usage examples_PHP tutorial

12 Jul 2016

Simple paging class implemented in PHP and usage examples, PHP paging usage examples. Simple paging class and usage examples implemented in PHP, PHP paging usage examples This article describes the simple paging class and usage examples implemented in PHP. Share it with everyone for your reference, the details are as follows: php/

Share PHP multifunctional image processing class, _PHP tutorial Share PHP multifunctional image processing class, _PHP tutorial

12 Jul 2016

Share php multifunctional image processing class. Share PHP multi-functional image processing class. The example in this article shares the multi-functional PHP image processing class for your reference. The specific content is as follows php /** * Image.class.php Image processing class * @a

PHP implements customizable style paging class, php custom style paging_PHP tutorial PHP implements customizable style paging class, php custom style paging_PHP tutorial

12 Jul 2016

PHP implements customizable style paging class, PHP custom style paging. PHP implements customizable style paging class, php custom style paging. This article shares an example of PHP implementing customizable style paging class for your reference. The specific content is as follows php

PHP implements paging class suitable for file content operations, _PHP tutorial PHP implements paging class suitable for file content operations, _PHP tutorial

12 Jul 2016

PHP implements paging classes suitable for file content operations. PHP implements the paging class suitable for file content operations. This article shares an example of PHP implementing the paging class for file content operations. It is emphasized that it is only for file operations for your reference.

See all articles