De Pagenumber Class:

[code]
<?php

/********
*	Show all errors
********/
error_reporting(E_ALL);
ini_set("display_errors", 1);


/********
*	Define Some vars
********/
define("MIN_PER_PAGE", 5);
define("MAX_PER_PAGE", 40);
define("DEF_PER_PAGE", 15);
define("THIS_PAGE", $_SERVER['PHP_SELF']);


/********
*	CLASS PAGE NUMBERS
********/
class Page_numbers
{
	var $table;
	var $condition;
	var $link_id;
	var $total_records;
	var $mpp;
	var $total_pages;
	var $page;
	var $offset;
	var $query_string;


	/********
	*	Constructor, setting some vars
	********/
	function Page_numbers($table, $condition="", $link_id=NULL)
	{
		$this->table = $table;
		$this->condition = $condition;
		$this->link_id = $link_id;
		$this->total_records = $this->count_records();
		$this->mpp = isset($_GET['mpp']) && is_numeric($_GET['mpp']) && $_GET['mpp'] >= MIN_PER_PAGE && $_GET['mpp'] <= MAX_PER_PAGE ? $_GET['mpp'] : DEF_PER_PAGE;
		$this->total_pages = ceil($this->total_records / $this->mpp);
		$this->page = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 && $_GET['page'] <= $this->total_pages ? $_GET['page'] : 1;
		$this->offset = ($this->page - 1) * $this->mpp;
		$this->query_string = $this->get_query_string();
	}


	/********
	*	Records tellen voor het uitrekenen van de pagenumbers
	********/
	function count_records()
	{
		$res = @mysql_query("SELECT count(*) FROM ".$this->table." ".$this->condition, $this->link_id);
		return @mysql_result($res, 0, "count(*)");
	}


	/********
	*	Data uit de database trekken van het pagenummer waar we op zitten
	********/
	function fetch_data($fields="*", $order="")
	{
		$res = @mysql_query("SELECT ".$fields." FROM ".$this->table." ".$this->condition." ".$order." LIMIT ".$this->offset.",".$this->mpp);
		while($row = mysql_fetch_assoc($res))
		{
			$data[] = $row;
		}
		return $data;
	}


	/********
	*	query sting opmaken
	********/
	function get_query_string($query_string="")
	{
		foreach($_GET as $key => $value)
		{
			if($key != 'page' && $key != 'mpp')
			{
				$query_string .= '&amp;'.$key.'='.$value;
			}
		}
		return $query_string;
	}


	/********
	*	Message Per Page upmaken en terug geven.
	********/
	function show_mpp()
	{
		$str = '<script type="text/javascript" language="javascript1.5">
		<!--
		function openUrl()
		{
			var control = document.getElementById(\'mpp\');
			window.location = "'.THIS_PAGE.'?page=1&mpp="+control.options[control.selectedIndex].value+"'.str_replace('&amp;', '&', $this->query_string).'";
		}
		//-->
		</script>
		<select id="mpp" onchange="openUrl();">';
		
		for($i=MIN_PER_PAGE; $i<=MAX_PER_PAGE; $i+=5)
		{
			$str .= '<option value="'.$i.'"'.($i == $this->mpp ? ' selected="selected"': '').'>'.$i.'</option>'."\r\n";
		}
		
		return $str.'</select>';
	}		


	/********
	*	Previous & Next links
	********/
	function prev_next()
	{
		$str = ($this->page > 1) ? '<a href="index.php?page='.($this->page-1).'&amp;mpp='.$this->mpp.$this->query_string.'" title="Vorige Pagina">&laquo;&laquo;</a>' : '<span style="color:#aaa">&laquo;&laquo;</span>';
		$str .= '&nbsp;&nbsp;&nbsp;';
		$str .= ($this->page < $this->total_pages) ? '<a href="index.php?page='.($this->page+1).'&amp;mpp='.$this->mpp.$this->query_string.'" title="Volgende Pagina">&raquo;&raquo;</a>' : '<span style="color:#aaa">&raquo;&raquo;</span>';
	
		return $str;
	}


	/********
	*	Pagenumbers opmaken en uitspugen
	********/
	function show_page_numbers($num_page_links=7)
	{
		if($this->total_pages > 1)
		{
			$num_page_links = $num_page_links % 2 ? $num_page_links : $num_page_links + 1;
			
			$pagenumbers = 'Pagina: <strong>'.$this->page.'</strong> van '.$this->total_pages.'<br />';
			
			if($this->total_pages > $num_page_links)
			{
				
				$cutoff = floor($num_page_links / 2);
				
				$start = $this->page - $cutoff;
				$end   = $this->page + $cutoff;


				/********
				*	No Pagenumbers Less then 1 && Greater then total_pages
				********/
				while($start < 1)					{ $start++; $end++; }
				while($end > $this->total_pages)	{ $start--; $end--; }


				/********
				*	Pagina nummers opmaken en uitspugen
				********/
				if($this->page > $cutoff + 1) { $pagenumbers .= '<a href="'.THIS_PAGE.'?page=1&amp;mpp='.$this->mpp.$this->query_string.'" title="First Page (1)">...</a>&nbsp; '; }
				
				for($i=$start; $i<=$end; $i++)
				{
					$pagenumbers .= ($i == $this->page) ? '<strong style="text-decoration:underline;">'.$i.'</strong>&nbsp; '."\r\n" : '<a href="'.THIS_PAGE.'?page='.$i.'&amp;mpp='.$this->mpp.$this->query_string.'" title="Go to Page '.$i.'">'.$i.'</a>&nbsp; '."\r\n";
				}
				
				if($this->page < $this->total_pages - $cutoff) { $pagenumbers .= '<a href="'.THIS_PAGE.'?page='.$this->total_pages.'&amp;mpp='.$this->mpp.$this->query_string.'" title="Last Page ('.$this->total_pages.')">...</a>&nbsp; '; }
				
			}
			else
			{
				for($i=1; $i<=$this->total_pages; $i++)
				{
					$pagenumbers .= ($i == $this->page) ? '<strong style="text-decoration:underline;">'.$i.'</strong>&nbsp; '."\r\n" : '<a href="'.THIS_PAGE.'?page='.$i.'&amp;mpp='.$this->mpp.$this->query_string.'" title="Go to Page '.$i.'">'.$i.'</a>&nbsp; '."\r\n";
				}
			}
			return rtrim($pagenumbers);
		}
		else
		{
			return NULL;
		}
	}


}
/* END CLASS */

?>
[/code]


Het aanroepen / inbouwen van de class (voorbeeld)

[code]
<!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=iso-8859-1" />
<title>Pagenumber Class - by Nano 2006</title>
<style type="text/css">
body {
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:12px;
	color:#006;
	line-height:18px;
	margin:40px;
}
a {
	color:#08f;
	text-decoration:none;
}
a:hover {
	color:#f00;
}
h1 {
	font-size:24px;
	color:#369;
	margin:0px 0px 30px 0px;
}
</style>
</head>
<body>
<h1>Page Number Class</h1>
<?php


/********
*	Connecten met mysql
********/
$link_id = @mysql_connect("localhost", "***", "***");
@mysql_select_db("***", $link_id);



/********
*	Pagina nummer class aanroepen
********/
@require("class_pagenumbers.php");
$page_nums = new Page_numbers("guestbook", "WHERE blocked='N'", $link_id);

$page_numbers = $page_nums->show_page_numbers(7);
$mpp = $page_nums->show_mpp();
$prev_next = $page_nums->prev_next();
$data = $page_nums->fetch_data("name", "ORDER BY id DESC");



/********
*	Pagina Nummers en Berichten Per Pagina uitspugen naar browser
********/
echo '<table cellpadding="0" cellspacing="0" style="width:450px; margin-bottom:30px;">
	<tr>
		<td>'.$page_numbers.'</td>
		<td align="right" valign="bottom">Berichten Per Pagina: '.$mpp.'</td>
	</tr>
</table>';



/********
*	Data uitspugen naar de browser
********/
foreach($data as $key => $array)
{
	echo $array['name']."<br />\r\n";
}



/********
*	Previous & Next Links
********/
echo '<br /><br />'.$prev_next;


?>
</body>
</html>
[/code]