N
nick
Guest
Pagination of php scripts can be a headache sometimes.
I have developed many scripts throughout my career as a php web developer. But most of my projects didn't needed php pagination in it.
Two years ago I came across some projects of mine which needed the pagination in it to make it more stable and extensible alowing the site to be browsable and more faster in navigation.
The above code will help you in implementing the pagination in your own php scripts and projects.
If you need any help in implementing this pagination function then please ask me over here or PM me.
I have developed many scripts throughout my career as a php web developer. But most of my projects didn't needed php pagination in it.
Two years ago I came across some projects of mine which needed the pagination in it to make it more stable and extensible alowing the site to be browsable and more faster in navigation.
PHP:
<?php
// Navigation
if($page == 1)
{
$prev = 1;
$next = 2;
}
else
{
$prev = $page - 1;
$next = $page + 1;
}
$r = mysql_query("Select COUNT(ID) from tblpages");
while ( $row = mysql_fetch_array( $r ) )
{
$cntr = $row['COUNT(ID)'];
}
// Now we have the count in cntr
$last = $cntr / 10;
settype($last, "Integer");
$last = $last + 1;
// Now final last check
if($next >= $last)
{
$next = $last;
}
$first = 1;
echo "<a href='page$first.html'>First</a> | ";
echo "<a href='page$prev.html'>Prev</a> | ";
echo "<a href='page$next.html'>Next</a> | ";
echo "<a href='page$last.html'>Last</a>";
?>
The above code will help you in implementing the pagination in your own php scripts and projects.
If you need any help in implementing this pagination function then please ask me over here or PM me.