PHP code example of faurelia / t2-simple-pagination

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

    

faurelia / t2-simple-pagination example snippets




// 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);

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

 for ($i = $pagination->min_page; $i <= $pagination->max_page; $i++): 

 if ($pagination->prev_page): 

 if ($pagination->num_page):