Home >php教程 >php手册 >分享一个自己写的分页

分享一个自己写的分页

WBOY
WBOYOriginal
2016-06-07 11:35:082407browse

分页
ArticleController        $articleList=M('article');<br>         $pNum=7;<br>         $page=I('get.p');<br>         $p=$page?$page:1;<br>         $pstart=($p-1)*$pNum;<br>         $pcount=ceil($articleList->count()/$pNum);//总页数<br>         $prev=$p==1?0:$p-1;<br>         $next=$p>=$pcount?0:$p+1;<br> <br>         $omitPage=3;<br>         $nstart=$p-$omitPage         if($p>4){<br>             $one = '<a>1</a>...';<br>             $this->assign('one',$one);<br>         }<br>         $listp='';<br>         for($i=$nstart;$i             if($i>$pcount)break;<br> <br>             if($i==$p){<br>                 $listp.='<span>'.$i.'</span>';<br>             }else{<br>                 $listp.='<a>'.$i.'</a>';<br>             }<br>         }<br>         $this->assign('listp',$listp);<br>         if($p             $hou = '... <a>'.$pcount.'</a>';<br>             $this->assign('hou',$hou);<br>         }<br>         $this->assign('pcount',$pcount);<br> <br>         $this->assign('p',$p);<br>         $this->assign('prev',$prev);<br>         $this->assign('next',$next);<br> <br> $article=$articleList->limit("$pstart,$pNum")->select();<br> $this->assign('article',$article);<br> $this->display();Article.html<if><else></else><a>$prev))}>">上一页</a></if><br> <br> <if><else></else><a>$next))}>">下一页</a></if><br> 当前第{$p}页 总共{$pcount}页样式:
上一页 1...456789... 13 下一页 当前第7页 总共13页
使用过程中发现什么问题请指出.

AD:真正免费,域名+虚机+企业邮箱=0元

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