我有自定义 PHP 站点并使用此脚本进行分页。
echo "Page <strong>$pagenum</strong> of <strong>$last</strong><br><br>";
if ($pagenum == 1)
{
}
else
{
echo "<li> <a href='{$_SERVER['PHP_SELF']}?pagenum=1'><strong>First page</strong></a></li>";
echo " ";
$previous = $pagenum-1;
echo "<li> <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'>".$previous."</a></li>";
}
echo "";
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " .... <li><a href='{$_SERVER['PHP_SELF']}?pagenum=$next'> ".$next."</a></li>";
echo " ";
echo "<li><a href='{$_SERVER['PHP_SELF']}?pagenum=$last'><strong>Last page</strong></a></li>";
}
这仅显示最后两页,甚至不显示第一页。如何自定义它以显示前 5 页和后 5 页。