Home  >  Article  >  Backend Development  >  使用php分页类实现简单分类

使用php分页类实现简单分类

WBOY
WBOYOriginal
2016-06-23 13:47:21760browse

分页类参考地址:http://blog.csdn.net/buyingfei8888/article/details/40260127

just soso。

实现分页主要分为4步:

1 引入分页类

2 实例化分页类

3 将其组装到sql语句中

4 打印出分页效果

代码:

<?php //数据库连接$link = mysql_connect('127.0.0.1','root',''); mysql_select_db('php0507',$link);//设置字符集 mysql_query('set names utf8');   // //获得总记录数 $sql_1 = mysql_query('select count(*) as count from sw_goods'); //返回一个资源型变量 $rzt_1 = mysql_fetch_assoc($sql_1); $cnt = $rzt_1['count'];// while($rzt_1 = mysql_fetch_assoc($sql_1)){//     echo $rzt_1['count'];// } $per = 6; //每页显示记录数 require_once('page.class.php'); $page =  new Page($cnt , $per);  //获得要查询信息  $sql_2 = mysql_query("select * from sw_goods $page->limit");  while($rzt_2 = mysql_fetch_assoc($sql_2)){     echo $rzt_2['goods_id'].'-----'.$rzt_2['goods_name'].'<br>'; } echo $page->fpage();?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn