Home >php教程 >php手册 >bootstrap分页函数

bootstrap分页函数

WBOY
WBOYOriginal
2016-06-07 11:42:241572browse

bootstrap分页函数
#bug较多 请勿使用#
<?php <br /> <br> // 总页数, 一页多少个, 显示多少个分页, 当前页数<br> function boot_page($count, $item, $list, $p)<br> {<br>     // 最大页数<br>     $max = ceil($count / $item);<br> <br>     if($max      {<br>         $page = "";<br>     }<br>     else<br>     {<br>         // 首页<br>         $page = '<li><a>«</a></li>';<br>         <br>         // 显示的第一个<br>         $start = $p - floor($list / 2);<br>         if($start          {<br>             $start = 1;<br>         }<br>         // 显示的最后一个<br>         $stop = $p + floor($list / 2);<br>         if($stop > $max)<br>         {<br>             $stop = $max;<br>         }<br>         <br>         for($i = $start; $i          {<br>             if($i == $p)<br>             {<br>                 // 选中当前页<br>                 $page .= '<li><span>'.$i.'</span></li>';<br>             }<br>             else<br>             {<br>                 $page .= '<li><a>'.$i.'</a></li>';<br>             }<br>         }<br>         <br>         // 末页<br>         $page .= '<li><a>»</a></li>';<br>     }<br> <br>     return $page;<br> }public function index($p = 1)<br>     {<br>         $db = M("shop");<br>         <br>         $data = $db->page($p, 10)->order("id desc")->select();<br>         $this->assign("data", $data);<br> <br>         $page = boot_page($db->count(), 10, 5, $p);<br>         $this->assign("page", $page);<br>         <br>         $this->display();<br>     }<div> <br>         <ul> <br>             {$page}<br>         </ul> <br>     </div>

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