简单实用php mysql分页代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-09-11 20:48:16 浏览: 评论:
- $qh=mysql_query("select count(*) as rcnt from table where your_condition_here order by whatever");
- $data=mysql_fetch_array($qh);
- $nr=$data["rcnt"];
-
- if (emptyempty($offset))
- {
- $offset=0;
- }
-
- $result=mysql_query("select id,name,phone from table where your_condition_here order by whatever limit $offset, 20");
-
- while ($data=mysql_fetch_array($result))
- {
-
- }
-
- if(!$offset)
- {
- $preoffset=$offset-20;
- print "<a href="$php_self?offset=$preoffset">前一页</a> ";
- }
-
- $pages=ceil($nr/20);
- for ($i=1; $i <= $pages; $i++)
- {
- $newoffset=20*$i;
- print "<a href="$php_self?offset=$newoffset">$i</a> ";
- }
-
- if ($pages!=0 && ($newoffset/20)!=$pages)
- {
- print "<a href="$php_self?offset=$newoffset">下一页</a> ";
- }
分享到:
相关文章
- ·php分页代码与分页原理(2013-11-12)
- ·PHP分页显示制作(2013-11-13)
- ·PHP实现翻页跳转功能(2013-11-13)
- ·自定义PHP分页函数(2013-11-13)
- ·小谈PHP&MYSQL分页原理及实现(2013-11-13)
- ·php中分页显示文章标题(2013-12-10)
- ·PHP MySQL分页显示(2013-12-10)
- ·一款php分页代码(2013-12-16)
- ·php分页代码(2013-12-16)
- ·PHP+AJAX无刷新分页实现代码详解(2014-01-03)
- ·PHP 分页代码与分页原理解析(2014-01-06)
- ·php文章内容分页实例程序(2014-01-07)
- ·php中分页程序之基于留言板详解(2014-01-15)
- ·php分页可利用表格来分页类(2014-01-15)
- ·简单入门级php分页代码(2014-05-10)
- ·PHP简单分页函数代码总结(2014-06-18)