php 数据分页显示 多页如何优化
如图,当数据很多时,每页的页数都显示出来了,以下是当前的代码,如何优化啊?<?phpecho"<divalign='center'>共有".$totalPage."页("...
如图,当数据很多时,每页的页数都显示出来了,以下是当前的代码,如何优化啊?
<?php
echo "<div align='center'>共有".$totalPage."页(".$page."/".$totalPage.")<br>";
//显示分页数
for ($i=1;$i<$page;$i++)
echo "<a href='original_data_info.php?page=".$i."'>第".$i ."页</a> ";
echo "第".$page."页 ";
for ($i=$page+1;$i<=$totalPage;$i++)
echo "<a href='original_data_info.php?page=".$i."'>第".$i ."页</a> ";
echo "<br>";
//显示转到页数
//echo "<form action='' method='post'> ";
echo "<form action='' method='get'> ";
//计算首页、上一页、下一页、尾页的页数值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$totalPage;
if ($page>1)
{
echo "<a href='original_data_info.php?page=".$first."'>首页</a> ";
echo "<a href='original_data_info.php?page=".$prev."'>上一页</a> ";
}
if ($page<$totalPage)
{
echo "<a href='original_data_info.php?page=".$next."'>下一页</a> ";
echo "<a href='original_data_info.php?page=".$last."'>尾页</a> ";
}
echo "转到<input type=text name='page' size='2' value=".$page.">页";
echo "<input type=submit name='submit' value='跳转' style='width: 60px; height: 30px;'>";
echo "<input type='button' name='button' value='返回' onclick='fanhui()' style='width: 60px; height: 30px;' />";
echo "</form>"; 展开
<?php
echo "<div align='center'>共有".$totalPage."页(".$page."/".$totalPage.")<br>";
//显示分页数
for ($i=1;$i<$page;$i++)
echo "<a href='original_data_info.php?page=".$i."'>第".$i ."页</a> ";
echo "第".$page."页 ";
for ($i=$page+1;$i<=$totalPage;$i++)
echo "<a href='original_data_info.php?page=".$i."'>第".$i ."页</a> ";
echo "<br>";
//显示转到页数
//echo "<form action='' method='post'> ";
echo "<form action='' method='get'> ";
//计算首页、上一页、下一页、尾页的页数值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$totalPage;
if ($page>1)
{
echo "<a href='original_data_info.php?page=".$first."'>首页</a> ";
echo "<a href='original_data_info.php?page=".$prev."'>上一页</a> ";
}
if ($page<$totalPage)
{
echo "<a href='original_data_info.php?page=".$next."'>下一页</a> ";
echo "<a href='original_data_info.php?page=".$last."'>尾页</a> ";
}
echo "转到<input type=text name='page' size='2' value=".$page.">页";
echo "<input type=submit name='submit' value='跳转' style='width: 60px; height: 30px;'>";
echo "<input type='button' name='button' value='返回' onclick='fanhui()' style='width: 60px; height: 30px;' />";
echo "</form>"; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询