0
我有一个PHP分页,当在论坛主题上每页所需数量超过所需数量时使用。 (15)它只能让你去上一页和下一页。我需要找到一种方法来制作最后一页的链接。这里是我的代码:PHP - 分页最后一页?
$resulte = mysqli_query($conexion, "SELECT * FROM forumcomments WHERE forum='$id'");
$getnumbers = mysqli_num_rows($resulte);
$howmuchpost = $page * 15;
$pageplus = $page + 1;
$pageminus = $page - 1;
$howmuchpostminus = $howmuchpost - 15;
$postsleft = $getnumbers - $howmuchpostminus;
if ($postsleft >= 15) {$nextpage = 'true';}
if ($howmuchpostminus >= 15 && $page != 1) {$previouspage = 'true';}
$posts_sql = "SELECT * FROM forumcomments WHERE forum = $id LIMIT ".$howmuchpostminus.", 15";
$posts_result = mysqli_query($conexion, $posts_sql);
//Display posts
$result2 = mysqli_query($conexion, "SELECT * FROM forumcomments WHERE forum='$id' ORDER BY id LIMIT $howmuchpostminus, $howmuchpost") or die(mysqli_error($conexion));
$num = mysqli_num_rows($result2);
if(!$posts_result)
{
echo '<tr><td>The posts could not be displayed, please try again later.</tr></td></table>';
}else{
while($rows = mysqli_fetch_assoc($posts_result)){
// Now you obviously have the looping data here, removed because I don't think this is really needed.
}
}
如果有人可以帮忙,我将不胜感激。谢谢。
您已经在脚本中拥有所有必要的值 - 因此这只是简单_math_ ... – CBroe