我有段时间没有更新网页上的分页了,现在我想要添加“第一页”和“最后一页”的链接到我的分页中,同时当搜索结果过长时也需要添加“...”。例如,我想要实现以下示例中的效果。请问谁能帮我修复代码以便我可以更新我的网站。谢谢。
First Previous 1 2 3 4 5 6 7 ... 199 200 Next Last
我目前使用我的代码显示以下内容。
Previous 1 2 3 4 5 6 7 Next
这是我的分页代码的一部分,用于显示链接。
if ($pages > 1) {
echo '<br /><p>';
$current_page = ($start/$display) + 1;
if ($current_page != 1) {
echo '<a href="index.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
}
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="index.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo '<span>' . $i . '</span> ';
}
}
if ($current_page != $pages) {
echo '<a href="index.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
}
echo '</p>';
}