PHPackages                             faurelia/t2-simple-pagination - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. faurelia/t2-simple-pagination

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

faurelia/t2-simple-pagination
=============================

A simple PHP pagination (with Bootstrap 3 example)

v1.0.1(8y ago)126MITPHPPHP &gt;=5.3.0

Since Aug 4Pushed 2y agoCompare

[ Source](https://github.com/faurelia/t2-simple-pagination)[ Packagist](https://packagist.org/packages/faurelia/t2-simple-pagination)[ Docs](https://github.com/faurelia/t2-simple-pagination)[ RSS](/packages/faurelia-t2-simple-pagination/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)DependenciesVersions (2)Used By (0)

T2 Simple Pagination
====================

[](#t2-simple-pagination)

A Simple PHP Pagination library (with Bootstrap 3 example)

Installation
------------

[](#installation)

```
require_once '/path/to/t2-simple-pagination/T2SimplePagination.php';
```

Usage
-----

[](#usage)

Initialize `T2SimplePagination` providing the 2 required parameters, `total` and `page` as well as additional settings.

```
// get the current page
$page = isset($_GET['p']) ? $_GET['p'] : 1;

// count total data from your record source. ie: DB or a file
$total = DB::count($data);

// set the number of items to display per page
$per_page = 10;

// set the number of page links to display
$range = 7; // IMPORTANT: please use odd numbers ONLY!!!

$pagination = new T2SimplePagination($total, $page, $per_page, $range);
```

Then extract the records by using the `offset` and `per_page` properties.

```
$query = "SELECT * FROM my_table LIMIT {$pagination->offset}, {$pagination->per_page}"
```

See the class [Properties](#properties) below for more details.

#### Page Links

[](#page-links)

```
