PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of mohsen movahed   Easy Pagination Class   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: example
Class: Easy Pagination Class
Generate links to browse paginated listings
Author: By
Last change: update codes
Date: 10 years ago
Size: 4,737 bytes
 

Contents

Class file image Download
<!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>