Added the compatibility with url.
PHP Code:
<?php
$cnt= 100; //set to value in database
if(isset($_GET['page']))
$currentpage = $_GET['page'];
else
$currentpage = 1; // Whatever you wanna use.
$current = 1;
$limit = 20; //Or set to other value, or user defined.
while($current <= $cnt)
{
$thislast = $current + $limit;
$url = "?page=" . $currentpage;
if($thislast > $cnt)
{
$thislast = $cnt;
}
if($current == ((($currentpage - 1) * 20) + 1))
{
echo '<p class = "paginationBold">'. $current . ' - ' . $thislast . '</p>';
}
else
{
echo '<a class = "paginationLink" href = "http://localhost/testing.php?page=' . ((int)($current / 20) + 1) . '">' . $current . ' - ' . $thislast . '</a>' ;
}
$current += $limit; //Added this to update $current. Was missing.
}
?>
Quote:
Originally Posted by mfoland
I got it figured out.. but My start = 0 should be showing 1-20 on the pagination but it's showing 1-21.. Very interesting!
|
1 + 20 = 21
But you can easy fix that.