diversen/simple-pager

This package is abandoned and no longer maintained. No replacement package was suggested.

A simple pager wrapper around pear-pager

v1.3.29 2017-02-03 18:29 UTC

This package is auto-updated.

Last update: 2021-07-20 10:10:50 UTC


README

The pagination class is a simple wrapper around PEAR::Pager

It works by knowing the the $_GET['from'] part of the query, and from this param the class knows what will be the next page in the set. You don't need to think about this, as the pagination class will take care of this:

Install

As with all packages that depends on pear, you will need to add pear to repositories section.

{
    "repositories": [
        {
            "type": "pear",
            "url": "https://pear.php.net"
        }

    ],
    "require": {
        "diversen/simple-pager": "^1.3"

    }
}

If you have pear in repositories you can install by doing:

composer require diversen/simple-pager

Example

use diversen\pagination;

// Get a count of rows from a database
// A database query to get the number of rows
// You will need your own way of getting your count of rows
$num_rows = q::numRows('mailer_archive')->fetch();
$per_page = 50;   
     
// Initialize the paginate class, with the total number
// of pages and how many per page. 
$p = new pagination($num_rows, $per_page);

// the rows to display
$rows = q::select('mailer_archive')->
            limit($p->from, $per_page)->
            fetch();

// Display the rows 
foreach($rows as $row) {
    print_r($row);
}
            
// Echo the pager data. 
echo $p->getPagerHTML();

CSS

You can find a CSS example in css/example.css