Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Narong  >  DS Pager  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: test pager
Class: DS Pager
Show links to browse listings split in pages
Author: By
Last change: start connect
Date: 2010-02-23 22:12
Size: 2,851 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body { font:13px Tahoma, Geneva, sans-serif; }
.css-pager a { text-decoration:none; color:#666; background:#F4F4F4; border:1px solid #e0e0e0;
                                 padding:2px 5px; margin:2px; font-weight:700; font-size:11px; }
.css-pager a:hover { text-decoration:none; color:#fff; background:#0A85CB; border:1px solid #3af; 
                                         padding:2px 5px; margin:2px; }
.current_page { background-color:#0A85CB; border:1px solid #3af; padding:2px 5px; margin:2px; color:#fff; font-weight:700; font-size:11px; }
</style>
</head>
<body>
<?php
    
require_once ('start_connect.inc.php');
    require_once (
'class_pager.php');
    
    
/**
     * string query
     */
    
$command 'SELECT * FROM test_table';
    
    
/**
     * get object result from database
     */ 
    
$result  mysql_query($command);
    
    
/*
     * Configuration pager
     */
    
$config['url_page'] = 'index.php?page=';
    
$config['all_recs'] = mysql_num_rows($result);    // all row of data
    
$config['scr_page'] = 10;    // scroll page
    
$config['per_page'] = 5;    // per pager
    
$config['cur_page'] = ($_GET['page']) ? $_GET['page'] : 1;    // current page
    
$config['act_page'] = 'class="current_page"';    // class css current page
    
$config['css_page'] = 'class="css-pager"';    // clss css area split page
    
$config['first'] = '&laquo; First';    // first page
    
$config['previous'] = '&lsaquo; Prev';    // previous page
    
$config['next']  = 'Next &rsaquo;';    // next page
    
$config['last']  = 'Last &raquo;';    // last page
    
    /**
     * create pager instance
     */
    
$pager = new Pager($config);
    
    
/**
     * display pager up data
     */
    
try {
        
$pager->createPager();
    } 
    catch(
Exception $e) { echo $e->getMessage(); } 
    
    
/**
     * display data
     */
    
$result mysql_query($command." ORDER BY id ASC LIMIT ".$pager->limitStart().", ".$config['per_page']) or die (mysql_error());
    echo 
' <span>ID.</span>';
    echo 
' &nbsp;&nbsp; <span>Name</span>&nbsp;&nbsp; ';
    echo 
' &nbsp;&nbsp; <span>Surname</span>&nbsp;&nbsp; ';
    echo 
' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Email';
    echo 
'<br />';
    if(
$result) { 
        while(
$rs mysql_fetch_assoc($result)) {
                echo 
'&nbsp;<span>'.$rs['id'].'</span>&nbsp;&nbsp;&nbsp;&nbsp; ';
                echo 
'<span>'.$rs['name'].'</span>&nbsp;&nbsp; ';
                echo 
'<span>'.$rs['surname'].'</span>&nbsp;&nbsp; ';
                echo 
'<a href="mailto:ranarong@live.com">'.$rs['email'].'</a>';
                echo 
'<br />';
        }
    }
    
    
/**
     * display pager down data
     */
    
try {
        
$pager->createPager();
    } 
    catch(
Exception $e) { echo $e->getMessage(); } 
    
?>
</body>
</html>