PHP code example of adamb / pagination

1. Go to this page and download the library: Download adamb/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/ */

    

adamb / pagination example snippets




ager\Pagination;

$numberOfRecords = 342; // This can also be generated from a database query
$pageURL = '/results.php';
$currentPage = $_GET['page'];
$resultsPerPage = 50; // This is the default value so can be removed

$pagination = new Pagination();
echo($pagination->paging($numberOfRecords, $pageURL, $currentPage, $resultsPerPage));




ager\Pagination;

$numberOfRecords = 342; // This can also be generated from a database query
$pageURL = '/results.php';
$currentPage = 3; //$_GET['page'];

$pagination = new Pagination();

$pagination->setPaginationClass('my_custom_pager')
           ->setActiveClass('this_is_active');

echo($pagination->paging($numberOfRecords, $pageURL, $currentPage));



ager\Pagination;

$numberOfRecords = 2042;
$pageURL = '/results.php';
$currentPage = 3; //$_GET['page'];
$resultsPerPage = 100;
$maximumLinksToDisplay = 9;
$displayArrows = false;
$additionalQuery = array(
    'search' => 'Hello', // urlencode($_GET['search']),
    'important_info' => 42, // urlencode($_GET['important_info']),
);

$pagination = new Pagination();

echo($pagination->paging($numberOfRecords, $pageURL, $currentPage, $resultsPerPage, $maximumLinksToDisplay, $displayArrows, $additionalQuery));
html
<ul class="pagination">
    <li class="active"><a href="/results.php?page=1" title="Page 1">1</a></li>
    <li><a href="/results.php?page=2" title="Page 2">2</a></li>
    <li><a href="/results.php?page=3" title="Page 3">3</a></li>
    <li><a href="/results.php?page=4" title="Page 4">4</a></li>
    <li><a href="/results.php?page=5" title="Page 5">5</a></li>
    <li><a href="/results.php?page=6" title="Page 6">6</a></li>
    <li><a href="/results.php?page=7" title="Page 7">7</a></li>
    <li><a href="/results.php?page=2" title="Page &gt;">&gt;</a></li>
    <li><a href="/results.php?page=7" title="Page &raquo;">&raquo;</a></li>
</ul>
html
<ul class="my_custom_pager">
    <li><a href="/results.php" title="Page &laquo;">&laquo;</a></li>
    <li><a href="/results.php?page=2" title="Page &lt;">&lt;</a></li>
    <li><a href="/results.php?page=1" title="Page 1">1</a></li>
    <li><a href="/results.php?page=2" title="Page 2">2</a></li>
    <li class="this_is_active"><a href="/results.php?page=3" title="Page 3">3</a></li>
    <li><a href="/results.php?page=4" title="Page 4">4</a></li>
    <li><a href="/results.php?page=5" title="Page 5">5</a></li>
    <li><a href="/results.php?page=6" title="Page 6">6</a></li>
    <li><a href="/results.php?page=7" title="Page 7">7</a></li>
    <li><a href="/results.php?page=4" title="Page &gt;">&gt;</a></li>
    <li><a href="/results.php?page=7" title="Page &raquo;">&raquo;</a></li>
</ul>
html
<ul class="pagination">
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=1" title="Page 1">1</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=2" title="Page 2">2</a></li>
    <li class="active"><a href="/results.php?search=Hello&amp;important_info=42&amp;page=3" title="Page 3">3</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=4" title="Page 4">4</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=5" title="Page 5">5</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=6" title="Page 6">6</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=7" title="Page 7">7</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=8" title="Page 8">8</a></li>
    <li><a href="/results.php?search=Hello&amp;important_info=42&amp;page=9" title="Page 9">9</a></li>
</ul>