1. Go to this page and download the library: Download kodhe/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/ */
kodhe / pagination example snippets
declare(strict_types=1);
Pagination;
$config = [
'base_url' => 'http://localhost/artikel/index/',
'total_rows' => 200, // total seluruh baris data
'per_page' => 10, // baris per halaman
'num_links' => 2, // jumlah link tetangga di kiri/kanan halaman aktif
'uri_segment'=> 3, // posisi segmen URI yang memuat nomor halaman
];
$pagination = new Pagination($config);
echo $pagination->create_links();
// <ul class="pagination">... <li><a href=".../index/2">2</a></li> ...</ul>