sp; <tr> <td width="50%" bgcolor="#E0E0E0"> <p align="center">标题</td> <td width="50%" bgcolor="#E0E0E0"> <p align="center">发布时间</td> </tr> <?php do { $i++; ?> <tr> <td width="50%"><?=$myrow["news_title"]?></td> <td width="50%"><?=$myrow["news_cont"]?></td> </tr> <?php } while ($myrow = mysql_fetch_array($rs)); echo "</table>"; } echo "<div align=''''center''''>共有".$pages."页(".$page."/".$pages.")"; for ($i=1;$i< $page;$i++) echo "<a href=''''fenye.php?page=".$i."''''>[".$i ."]</a> "; echo "[".$page."]"; for ($i=$page+1;$i<=$pages;$i++) echo "<a href=''''fenye.php?page=".$i."''''>[".$i ."]</a> "; echo "</div>"; ?> </body> </html> 五、总结 本例代码在windows2000 server+php4.4.0+mysql5.0.16上运行正常。该示例显示的分页格式是[1][2][3]…这样形式。假如想显示成“首页 上一页 下一页 尾页”这样形式,请加入以下代码: $first=1; $prev=$page-1; $next=$page+1; $last=$pages; if ($page > 1) { echo "<a href=''''fenye.php?page=".$first."''''>首页</a> "; echo "<a href=''''fenye.php?page=".$prev."''''>上一页</a> "; } if ($page < $pages) { echo "<a href=''''fenye.php?page=".$next."''''>下一页</a> "; echo "<a href=''''fenye.php?page=".$last."''''>尾页</a> "; } 其实,写分页显示代码是很简单的,只要掌握了它的工作原理。希望这篇文章能够带给那些需要这方面程序web程序员的帮助。
上一页 [1] [2] [MySql]PHP存取 Mysql 数据乱码终极解决方案 [MySql]解决Table xxx is marked as crashed and should … [MySql][MySQL]快速解决"is marked as crashed and shoul… [MySql]MySQL DELETE语法用法详解 [MySql]mysql中时间日期格式化 [MySql]修改mysql导入文件大小限制 [其他]MySql常用命令大全 [Web开发]把ACCESS的数据导入到Mysql中的方法详解 [MySql]解决mysql 1040错误Too many connections的方法 [系统软件]利用crontab系统每天定时备份MySQL数据库
|