hilmanrdn/pagination-allegri

There is no license information available for the latest version (dev-master) of this package.

simple pagination class

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 1

pkg:composer/hilmanrdn/pagination-allegri

dev-master 2016-12-15 08:39 UTC

This package is not auto-updated.

Last update: 2025-10-06 19:43:52 UTC


README

php pagination package, work with search query

#Install via composer

composer require "hilmanrdn/pagination-allegri":"dev-master"

#URL Example index.php?page=1 //normal
index.php?page=1&search=john&col=username //with search
Search value :will be what we're searching for
Col value :will be which column (on our database)

#How to use it

use PaginationAllegri\Pagination;
require_once 'vendor/autoload.php';

//put your database config as parameter
$pagination = new Pagination($host, $dbname, $user, $pass, $table);

//example here user data
$users = $pagination->get_data(); //all user data
$pages = $pagination->get_numbers(); //total page numbers

var_dump($users); //retreive all users data

//pagination
<? for ($i=1; $i<=$pages; $i++): ?>
    <? if($pagination->is_showable($i)): ?>
        <a class="<?=$pagination->is_active_page($i); ?>"
           href="?page=<?=$i . '' .$pagination->get_search_param() ?>">
            <?=$i ?>
        </a>
    <? endif; ?>
<? endfor; ?>

//previous page
<a href="?page=<?=$pagination->prev_page() . '' .$pagination->get_search_param()?>"> << </a>

//next page
<a href="?page=<?=$pagination->next_page() . '' .$pagination->get_search_param()?>"> >> </a>