PHP Classes

Easy Pagination Class: Generate links to browse paginated listings

Recommend this page to a friend!
  Info   Example   Demos   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 40%Total: 584 All time: 5,297 This week: 455Up
Version License PHP version Categories
easy-pagination-php 1.3GNU General Publi...5.0HTML, PHP 5
Description 

Author

This class can generate links to browse paginated listings.

It takes an array of parameters that define limit of items listed per page, the total number of items in the whole listing, and the number of the current page.

The class generates HTML links with a given base URL to let the user browse to the next and previous listing pages.

Picture of mohsen movahed
  Performance   Level  
Name: mohsen movahed <contact>
Classes: 1 package by
Country: Iran Iran
Age: 34
All time rank: 309256 in Iran Iran
Week rank: 192 Up1 in Iran Iran Up

Example

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>pagination</title>

    <meta charset='utf-8'>
    <style>
    *
    {
        direction: ltr;
    }
    .paging
    {
        margin: 65px auto;
        padding: 0;
        list-style: none;
    }

    .paging li
    {
        float: left;
        margin-left: 10px;
    }

    .paging li a
    {
        display: block;
        text-decoration: none;
        color: #717171;
        font-family: tahoma;
        font-size: 9pt;
        text-shadow: 0px 1px white;
        padding: 5px 8px;

        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;

        -webkit-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.35);
        -moz-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.35);
        box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.35);
        background-color: #e5e5e5;

        background: -webkit-linear-gradient(top, #e5e5e5 0%, #e8e8e8 100%);
        background: -moz-linear-gradient(top, #e5e5e5 0%, #e8e8e8 100%);
        background: -o-linear-gradient(top, #e5e5e5 0%, #e8e8e8 100%);
        background: -ms-linear-gradient(top, #e5e5e5 0%, #e8e8e8 100%);
        background: linear-gradient(top, #e5e5e5 0%, #e8e8e8 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e8e8e8',GradientType=0 );
    }

    .paging li a.current-page
    {
        color: white;
        text-shadow: 0px 1px #3f789f;

        -webkit-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.8);
        -moz-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.8);
        box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.8);
        background: #7cb9e5;

        background: -webkit-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
        background: -moz-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
        background: -o-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
        background: -ms-linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
        background: linear-gradient(top, #7cb9e5 0%, #57a1d8 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7cb9e5', endColorstr='#57a1d8',GradientType=0 );
    }

    .paging li a:hover
    {
        -webkit-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.55);
        -moz-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.55);
        box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.55);
        background: #fff;

        background: -webkit-linear-gradient(top, #fff 0%, #e8e8e8 100%);
        background: -moz-linear-gradient(top, #fff 0%, #e8e8e8 100%);
        background: -o-linear-gradient(top, #fff 0%, #e8e8e8 100%);
        background: -ms-linear-gradient(top, #fff 0%, #e8e8e8 100%);
        background: linear-gradient(top, #fff 0%, #e8e8e8 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff', endColorstr='#e8e8e8',GradientType=0 );
    }

    .paging li a:active, .paging li a.current-page:active
    {
        -webkit-box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.5), 0px 1px 1px 0px rgba(255,255,255,1) !important;
        -moz-box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.5), 0px 1px 1px 0px rgba(255,255,255,1) !important;
        box-shadow: inset 0px 1px 3px 0px rgba(0,0,0,0.5), 0px 1px 1px 0px rgba(255,255,255,1) !important;
    }

    .paging li a.current-page:hover
    {
        -webkit-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.9);
        -moz-box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.9);
        box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.9);
        background: #99cefc;

        background: -webkit-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
        background: -moz-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
        background: -o-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
        background: -ms-linear-gradient(top, #99cefc 0%, #57a1d8 100%);
        background: linear-gradient(top, #99cefc 0%, #57a1d8 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#99cefc', endColorstr='#57a1d8',GradientType=0 );
    }
    </style>

</head>
<body>

<?php
include_once 'pagination.php';

mysql_connect('localhost', 'root', '');
mysql_select_db('dbName');
mysql_query('set names \'utf8\'');
$total = mysql_query('select count(*) as `total` from posts');
$result = mysql_fetch_assoc($total);

$paging = new Pagination(
    array(
       
'items_per_page' => 5,
       
'total_records' => $result['total'],
       
'url_address' => 'http://example.com/?page=',
       
'current_page' => (isset($_GET['page']) ? $_GET['page'] : 1),
       
//'mode' => true,
       
)
    );

//$start = $paging->items_per_page * ($paging->current_page - 1);
//$limit = $paging->items_per_page;
$section = $paging->limit();

$start = $section['start'];
$limit = $section['limit'];
$result = mysql_query("select * from posts LIMIT $start, $limit");
while(
$row = mysql_fetch_assoc($result))
{
    echo
'<strong>' . $row['title'] . '</strong><hr>';
}

// display
$paging->display();
echo
'<br>';
$paging->recordsInfo();
echo
'<hr>';
$paging->pagesInfo();
?>

</body>
</html>


  pagingExternal page  
Screenshots (2)  
  • demo-2.jpg
  • demo-en.jpg
  Files folder image Files (5)  
File Role Description
Accessible without login Plain text file index.php Example example
Plain text file pagination.php Class pagination class
Accessible without login Plain text file pagination.sql Data sql file

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:584
This week:0
All time:5,297
This week:455Up
 User Ratings  
 
 All time
Utility:58%StarStarStar
Consistency:58%StarStarStar
Documentation:-
Examples:58%StarStarStar
Tests:-
Videos:-
Overall:40%StarStarStar
Rank:3764