PHP code example of php-pagination / php-pagination

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

    

php-pagination / php-pagination example snippets



agination\Pagination;
use Pagination\StrategySimple;

if ( isset($_GET['page']) && is_numeric($_GET['page']) )
$page = $_GET['page'];
else 
$page = 1;

//use pagination class with results, per page and page
$pagination = new Pagination(1000, 10, $page);
//get first page
$pagination->getFirstPage();
//get last page
$pagination->getLastPage();
//get previous page
$pagination->getPreviousPage();
//get next page
$pagination->getNextPage();
//get all indexes
$all = $pagination->getAllIndexesOfPages();
$iteratorAll = $all->getIterator();
//get indexes in page stylized
$indexes = $pagination->getIndexes(new StrategySimple(15));
$iterator = $indexes->getIterator();

//get start for sql queries (optional - Note: This paging does not use a bank connection)
$pagination->getStartForSqlQueries();