##1. 分页原理:
limit offset, sizeoffset:偏移量 offset=(当前页-1)*sizesize:每页显示条数
#2. 排序
order by ‘排序字段’ ‘正序或反序'
3. demo
$doctor=M('freegoods'); $num=I('page','1','intval');//当前页码 $pagesize=I('size','5','intval');//每页显示条数 $count=$doctor->count();//总条数 $sort=I('sort','id');//当 $order=I('order','asc'); $totalpage = ceil($count/$pagesize);//总页数 $offset = ($num-1)*$pagesize; $sql = "select id,doctorname,post,asktime,skill,storecode,gender,userimg from hx_doctor order by $sort $order limit $offset,$pagesize "; $info=$doctor->query($sql);