Location: PHPKode > scripts > New DB Class > new-db-class/show_paging.php
<?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          |
// | hide@address.com so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Jiri Kocman <hide@address.com>                          |
// +----------------------------------------------------------------------+

/**
* function show_paging
*
* Jednoducha funkce ktera slouzi jako priklad jak zobrazit strankovani vytvorene pomoci db triy.
*
* @package db_class
* @author Jiri Kocman - hide@address.com
* @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);
?>
Return current item: New DB Class