PHP code example of irfantoor / pagination

1. Go to this page and download the library: Download irfantoor/pagination library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

irfantoor / pagination example snippets


<html>
    <head>
        <style>
            .pagination a {text-decoration: none}

            /* from bootstrap.css */
            .pagination {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            padding-left: 0;
            list-style: none;
            border-radius: 0.25rem;
            }

            .page-link {
            position: relative;
            display: block;
            padding: 0.5rem 0.75rem;
            margin-left: -1px;
            line-height: 1.25;
            color: #007bff;
            background-color: #fff;
            border: 1px solid #dee2e6;
            }

            .page-link:hover {
            color: #0056b3;
            text-decoration: none;
            background-color: #e9ecef;
            border-color: #dee2e6;
            }

            .page-link:focus {
            z-index: 2;
            outline: 0;
            box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
            }

            .page-link:not(:disabled):not(.disabled) {
            cursor: pointer;
            }

            .page-item:first-child .page-link {
            margin-left: 0;
            border-top-left-radius: 0.25rem;
            border-bottom-left-radius: 0.25rem;
            }

            .page-item:last-child .page-link {
            border-top-right-radius: 0.25rem;
            border-bottom-right-radius: 0.25rem;
            }

            .page-item.active .page-link {
            z-index: 1;
            color: #fff;
            background-color: #007bff;
            border-color: #007bff;
            }

            .page-item.disabled .page-link {
            color: #6c757d;
            pointer-events: none;
            cursor: auto;
            background-color: #fff;
            border-color: #dee2e6;
            }
        </style>
    </head>
<body>


    



use IrfanTOOR\Pagiation;

$pagination = new Pagination([
    'base_url' => '/blog//',
    'per_page' => 20,
    'int_pages' => 9,
]);


$pagination->setBaseUrl('/users//');


$pagination->setPageComponent('page_no');
# now the url will be like : .../?page_no=3


$per_page = 100;
$pagination->setPerPage($per_page);


$pagination->setIntermediatePages(7);


$page = $pagination->currentPage();


# ...
$total = 10000; # from a database query for example
echo $pagination->html($total);       # normal pagination
echo $pagination->html($total, true); # reverse pagination