Jump to content

page pagination before & after


web_master

Recommended Posts

Hi,

 

I got a script for a pagination. Its work fine. Its print pages on bottom of page (after „PRINTED ELEMENT”). Is possible to print pages before "while" - mean on begin of page and on end of the page too. - or I need some other script?

 

Thnxs!

 

<?php
// Pagination
if(!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}

$max_results = 100;
$from = (($page * $max_results) - $max_results);


// Reload from dBase
$query_return = mysql_query("SELECT * FROM `dbase` ORDER BY `id` DESC LIMIT ".$from.", ".$max_results." ");

if(!$query_return) {
	print mysql_error();
	exit;
}

while($request = mysql_fetch_array($query_return)) {



	print $request['e_mail']; // !!! PRINTED ELEMENT !!!



}
// Pagination
$total_results = mysql_result(mysql_query("SELECT COUNT(*) AS NUM FROM `dbase`"),0);

$total_pages = ceil($total_results / $max_results);

print "<p class=\"TXT_PAGINATION\">";

if($page > 1) {
	$prev = ($page - 1);
	print " <a href=\"".$_SERVER['PHP_SELF']."?page=".$prev."\" class=\"TXT_PAGINATION_HREF\"><< Step back</a> ";
}


for($i = 1; $i <= $total_pages; $i++) {
	if(($page) == $i) {
		print " ".$i." ";
	}
	else { 
		print " [<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\" class=\"TXT_PAGINATION_HREF\">".$i."</a>] ";
	}
}

if($page < $total_pages) {
	$next = ($page + 1);
	print " <a href=\"".$_SERVER['PHP_SELF']."?page=".$next."\" class=\"TXT_PAGINATION_HREF\">Step forward >></a> ";
}
	print "</p>";
?>

Link to comment
https://forums.phpfreaks.com/topic/97581-page-pagination-before-after/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.