分页显示的代码:
<?php
}
while ($myrow = mysql_fetch_array($res));
}
?>
<?
echo "<div align='center'>共有".$pages."页(".$page."/".$pages.")<br>";
//显示分页数
for ($i=1;$i<$page;$i++)
echo "<a href='index.php?page=".$i."'>第".$i ."页</a> ";
echo "第".$page."页 ";
for ($i=$page+1;$i<=$pages;$i++)
echo "<a href='index.php?page=".$i."'>第".$i ."页</a> ";
echo "<br>";
//显示转到页数
echo "<form action='index.php' method='post'> ";
//计算首页、上一页、下一页、尾页的页数值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='index.php?page=".$first."'>首页</a> ";
echo "<a href='index.php?page=".$prev."'>上一页</a> ";
}
if ($page<$pages)
{
echo "<a href='index.php?page=".$next."'>下一页</a> ";
echo "<a href='index.php?page=".$last."'>尾页</a> ";
}
echo "转到<input type=text name='ys' size='2' value=".$page.">页";
echo "<input type=submit name='Submit' value='Go'>";
echo "</form>";
echo "</div>";
?>