我在数据库里有一个包含玩家点数的表。我的页面index.php显示了该表:
if (isset($_GET['page'])){
$pageload=intval($_GET['page']);
if ($pageload==1 || $pageload==""){
$Lpage=0;
}
else {
$Lpage=($pageload*10)-10;
}}
else{$Lpage=0;}
$expects="
SELECT id
, user_id
, sum(points) AS points
FROM expectation
GROUP
BY user_id
ORDER
BY points DESC
Limit $Lpage,10
";
$result_ex=mysqli_query($berikane,$expects);
$row_ex=mysqli_fetch_assoc($result_ex);
do{
$xx=$xx+1;
?>
<tr>
<td width="40" height="35" align="center"><?php echo $xx?></td>
<td width="170" height="35"><?php
echo $row_puid['username'];
?></td>
<td height="35" align="center"><a href="Details.php?<?php echo "uid=".$puid ?>"><?php echo $row_ex['points']?></a></td>
</tr>
<?php }while ($row_ex = mysqli_fetch_assoc($result_ex));
$expects2="SELECT id,user_id,sum(points) AS points FROM expectation GROUP BY user_id ORDER BY points DESC ";
$result_ex2=mysqli_query($berikane,$expects2);
$row_ex2=mysqli_fetch_assoc($result_ex2);
$pcount=mysqli_num_rows($result_ex2);
$pcount=$pcount/10;
$pcount=ceil($pcount);
?>
<tr>
<td height="35" colspan="3" align="center"><?php
for ($pg=1;$pg<=$pcount;$pg++){
?> <a href="index.php?page=<?php echo $pg ?>" style="text-decoration:none; font-size:18px"><?php echo $pg ?> </a><?php
}
?>
现在index.php显示表中的10行,我必须单击页数才能转到该页(1,2,3,…等),我想帮助用户单击一个按钮,然后将转到表中包含其排名的页面。我该怎么做?
2条答案
按热度按时间sy5wg1nm1#
我通过添加以下内容来解决:
yhxst69z2#
获取页码
获取当前用户点
统计所有比当前用户点数多的记录
除以每页显示的记录数
现在你应该知道页码了