<?php
// Code not directly relevant omitted (including lots of vars)
//Create pagination links
$first = "First";
$prev = "Prev";
$next = "Next";
$last = "Last";
if($current_page>1)
{
$prevPage = $current_page - 1;
$first = "<a href=\"test.php?page=1\">First</a>";
$prev = "<a href=\"test.php?page={$prevPage}\">Prev</a>";
}
if($current_page<$total_pages)
{
$nextPage = $current_page + 1;
$next = "<a href=\"test.php?page={$nextPage}\">Next</a>";
$last = "<a href=\"test.php?page={$total_pages}\">Last</a>";
}
?>
<html>
<title></title>
<body>
<h2>Here are the records for page <?php echo $current_page; ?></h2>
<ul>
<?php echo $slots; ?>
</ul>
Page <?php echo $current_page; ?> of <?php echo $total_pages; ?>
<br />
<?php echo "{$first} | {$prev} | {$next} | {$last}"; ?>
</body>
</html>
EDIT / UPDATE: 我刚刚意识到我有一个名为test.php的文件。我删除了它,但我想它仍然在我的网站中某种程度......然而,我改变了单词测试与作品。现在,当我点击下一步时,它会将我带到mydomain.com/works.php?page=2。但它显示404错误:/
有人可以告诉我在哪里搞砸了吗?谢谢!
答案 0 :(得分:0)
代码当然看起来不错;你确定问题出在 links 中吗?也许你出于其他原因被重定向到“正确的”页面?