• Welcome to NamesLot.com Domain Name Forum

    NamesLot.com Domain Name Forum offers a fully open forum to discuss domain industry news and a 0% commission marketplace for you to buy and sell domain names.

    We have reorganized our Marketplace so now it is easier to get attention to your domain while it is also easier for buyers to find the right domain name.

    If you want us to add more threads to our marketplace, please contact us! Listing on our marketplace as always, 100% free! Register NOW or Login HERE!

pagination of php scripts

  • Thread starter Thread starter nick
  • Start date Start date
Status
Not open for further replies.
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.

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.
 
Status
Not open for further replies.

Members online

Forum statistics

Threads
20,488
Messages
70,493
Members
44,656
Latest member
robertlogel
Active members today
6
New members today
1
New threads today
15
New posts today
17

Follow NamesLot on Twitter!

NamesLot proudly supported by

NamesLot proudly supported by

Top