PHP code example of peterujah / pagination

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

    

peterujah / pagination example snippets

 
 use Peterujah\NanoBlock\Pagination;
 $paging = new Pagination($rowCount, Pagination::LIST);
 $paging = new Pagination($rowCount, Pagination::LINK);
 
 $paging = new Pagination(100, Pagination::LIST);
 $paging->setLimit(20);
 $paging->setCurrentPage($_GET["page"]??1)->show();
 
 
 $paging = new Pagination(100, Pagination::LIST);
 $paging->setLimit(20);
 $html = $paging->setCurrentPage($_GET["page"]??1)->get();

use Peterujah\NanoBlock\Pagination;
// Configure page limit
$queryLimit = 30;
$queryPage = $_GET["n"]??1;
$queryStart = ($queryPage - 1) * $queryLimit;

// Query your database table
$users = (object) array(
    "users" => $conn->findUsers($queryStart, $queryLimit),
    "rowCount" => $conn->findTotalUsers()
);

// Initialize Pagination
$paging = new Pagination($users->rowCount, Pagination::LIST);
$paging->setLimit($queryLimit);
$paging->setCurrentPage($queryPage);

// Display your contents
foreach($users->users as $row){
    echo "<div>{$row->userFullname}</div>";
}
// Add pagination buttons
echo "<nav aria-label='Page navigation'>";
echo $paging->get();
echo "</nav>";
 php 
$paging->setAllowCss(true);