Jump to content

page navigator


the-botman

Recommended Posts

ok see what this does is splits pages that have to much on 1 page now say it has 13 pages it shows << 1 2 3 4 5 6 7 8 9 10 11 12 13 >> i want it to work like say i am on page 1  <<  2 3 4 5  6 >> or if i am on page 7 << 8 9 10 11 12 >> how do i do this, here is my code

<?php
function Page_Get_Amount($Row_Count, $Page_Limit) {
$Page_Amt = $Row_Count / $Page_Limit;
$Page_NewAmt = number_format($Page_Amt, 0); 
if ($Page_Amt > $Page_NewAmt) {
	$Page_Amt = $Page_NewAmt + 1;
} else {
	$Page_Amt = $Page_NewAmt;	
}
return $Page_Amt;
}

function Page_Get_Positions($Row_Count, $Page_Amount, $Page_Limit, $Page_Requested) {
$Page_Pos_End = $Page_Requested * $Page_Limit;
$Page_Pos_Start = $Page_Pos_End - $Page_Limit;

$Page_Pos_End = 	$Page_Pos_End;

if ($Page_Requested == $Page_Amount) {
	$Page_Pos_End = $Row_Count;
}
$Result[0] = $Page_Pos_Start;
$Result[1] = $Page_Pos_End;
return $Result;
}
function Page_Get_Navigator($Page_Url, $Page_Amount, $Page_Requested) {
$Result = "";

	if ($Page_Requested != 1) {
		$PrevPage = $Page_Requested -1;
		$Page_NewUrl = $Page_Url."&Page=".$PrevPage;
		$Result = $Result.'<a href="'.$Page_NewUrl.'">'."<<</a> ";
	} else {
		$Result = $Result.'<font color="#8A8989"><< </font>';

	}

	$J = 1;
	while ($J <= $Page_Amount) {
		$Page_NewUrl = $Page_Url."&Page=".$J;
			if ($J != $Page_Requested) {
				$Result = $Result.'<a href="'.$Page_NewUrl.'">'."$J</a> ";
			} else {
				$Result = $Result.'<font color="#FF0000">'."$J</font> ";
			}
		$J++;
	}

	if ($Page_Requested != $Page_Amount) {
		$NextPage = $Page_Requested +1;
		$Page_NewUrl = $Page_Url."&Page=".$NextPage;
		$Result = $Result.' <a href="'.$Page_NewUrl.'">'.">></a>";
	} else {
		$Result = $Result.'<font color="#8A8989"> >></font>';

	}
return '<font face="Verdana" size="2">'.$Result.'</font>';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/184167-page-navigator/
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.