Hello!
I hope you can help me please.
I'm using the following code for pagination on various pages of my site.
However, there appears to be a problem that when a page higher than 12 is selected, only the final figure appears.
For example, my list_logins.php contains enough for 350 pages (of 20 entries per page).
When the page is first loaded, it correctly reports:
Prev « 1 2 3 4 5 6 7 8 9 10 11 12 ... 350 » Next
However, when 12 or anything higher than 12 is selected, I simply see:
Prev « ... 350 » Next
...where it should be showing other figures too (such as when it first loads).
Any help fixing this (and generally tidying it up in case there's anything un-needed) would be great.
Code:
$num_rows is set before, let's say 350
$line_url also set up here too...
$entries=20;
echo " <p class=\"righttext\"><small>";
if (isset($_GET['list'])) {
$page = $_GET['list'];
} else {
$page=0;
}
$pages=$num_rows / $entries;
if (($num_rows % $entries)>0) { $pages++; }
if ($page+1>1) {
$prev=$page-1;
echo "<a href=\"list_logins.php?list=".$prev.$lineurl."\">Prev «</a> ";
} else {
echo "Prev « ";
}
if ($page>10) {
$from=$page-1;
} else {
$from=1;
$to=$from+11;
if ($to>$pages) { $to=$pages; }
}
for($i=$from; $i<=$to; $i++)
{
$iwhere=$i-1;
if ($iwhere==$page) {
echo "<strong><a href=\"list_logins.php?list=".$iwhere.$lineurl."\">".$i."</a></strong> ";
} else {
echo "<a href=\"list_logins.php?list=".$iwhere.$lineurl."\">".$i."</a> ";
}
}
if ($pages>$to)
{
$pages1=floor($pages)-1;
echo " ... <a href=\"list_logins.php?list=".$pages1.$lineurl."\">".floor($pages)."</a>";
}
if ($page+1<floor($pages))
{
$nex=$page+1;
echo " <a href=\"list_logins.php?list=".$nex.$lineurl."\">» Next</a>";
} else {
echo " » Next";
}
echo "</small></p>\n";
Thank you!