PHP Classes

File: show_paging.php

Recommend this page to a friend!
  Classes of Jiri Kocman   New DB Class   show_paging.php   Download  
File: show_paging.php
Role: Example script
Content type: text/plain
Description: sample PHP script for paging show
Class: New DB Class
Class for access MySQL and Sybase ASE database ser
Author: By
Last change:
Date: 21 years ago
Size: 3,810 bytes
 

Contents

Class file image Download
<?php
/* vim: set ts=2 sw=2: */
// +----------------------------------------------------------------------+
// | PHP version 4.0 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997 - 2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Jiri Kocman <jirka@komplikator.cz> |
// +----------------------------------------------------------------------+

/**
* function show_paging
*
* Jednoducha funkce ktera slouzi jako priklad jak zobrazit strankovani vytvorene pomoci db triy.
*
* @package db_class
* @author Jiri Kocman - jirka@komplikator.cz
* @version $Id: show_paging.php,v 1.1 2002/12/07 14:23:11 jirka Exp $
*/
function show_paging(&$db)
{
    echo
'<div align=center>';

    if (
$db->PAGING[1][1] == '')
    {
        echo
$db->PAGING[1][0];
    }
    else
    {
        echo
'<a href="show_paging.php?' . $db->PAGING[1][1] . '">' . $db->PAGING[1][0] . '</a>';
    }
       
    echo
'&nbsp;';

    if (
$db->PAGING[2][1] == '')
    {
        echo
$db->PAGING[2][0];
    }
    else
    {
        echo
'<a href="show_paging.php?' . $db->PAGING[2][1] . '">' . $db->PAGING[2][0] . '</a>';
    }

    echo
'&nbsp;&nbsp;&nbsp;';
       
    for (
$i = 5; $i<count($db->PAGING);$i++)
    {
        if (
$i > 5) echo '&nbsp;-&nbsp;';

        if (
$db->PAGING[$i][1] == '')
        {
            echo
$db->PAGING[$i][0];
        }
        else
        {
            echo
'<a href="show_paging.php?' . $db->PAGING[$i][1] . '">' . $db->PAGING[$i][0] . '</a>';
        }
    }

    echo
'&nbsp;&nbsp;&nbsp;';

    if (
$db->PAGING[3][1] == '')
    {
        echo
$db->PAGING[3][0];
    }
    else
    {
        echo
'<a href="show_paging.php?' . $db->PAGING[3][1] . '">' . $db->PAGING[3][0] . '</a>';
    }
   
    echo
'&nbsp;';

    if (
$db->PAGING[4][1] == '')
    {
        echo
$db->PAGING[4][0];
    }
    else
    {
        echo
'<a href="show_paging.php?' . $db->PAGING[4][1] . '">' . $db->PAGING[4][0] . '</a>';
    }

    echo
'<br>';
    echo
'Nalezeno ' . $db->PAGING[0][3] . ' záznam' . $db->PAGING[0][4];
    echo
'</div>';
}




/* --------------------------------------------------------------------------------- */
/* ----------------------------------- e x a m p l e ------------------------------- */
/* --------------------------------------------------------------------------------- */

require_once('../db_class_config.php'); // require db classu
require_once('../' . $_dbEngine . "_db_class.php");

$db = new db($_dbServer, $_dbUser, $_dbPass, true, $_dbName); // pripojeni k databazi

/* definice argumentu */
$args = array(
                           
PAGENUMBER => ($_REQUEST[PGN]) ? $_REQUEST[PGN] : 1,
                           
PERPAGE => 10,
                           
PERPAGELINKS => 10,
                           
JUMP => 10,
                           
VARNAME => 'PGN',
);

/* sql dotaz volany sl LIMIT pomoci metody Paging - vytvari se zaroven pole se strankovanim */
$db->db_Query('SELECT * FROM user' . $db->Paging(&$args,COUNT_QUERY,'SELECT COUNT(*) FROM user'));

/* zobrazujeme listovaci odkazy */
show_paging(&$db);

/* jednoduche zobrazeni SQL vysledku */
echo $db->show_data();

/* zobrazujeme listovaci odkazy */
show_paging($db);
?>