PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

bootstrap分页函数

原创
2016-06-07 11:42:24 1265浏览

bootstrap分页函数
#bug较多 请勿使用#

// 总页数, 一页多少个, 显示多少个分页, 当前页数
function boot_page($count, $item, $list, $p)
{
// 最大页数
$max = ceil($count / $item);

if($max {
$page = "";
}
else
{
// 首页
$page = '

  • «
  • ';

    // 显示的第一个
    $start = $p - floor($list / 2);
    if($start {
    $start = 1;
    }
    // 显示的最后一个
    $stop = $p + floor($list / 2);
    if($stop > $max)
    {
    $stop = $max;
    }

    for($i = $start; $i {
    if($i == $p)
    {
    // 选中当前页
    $page .= '
  • '.$i.'
  • ';
    }
    else
    {
    $page .= '
  • '.$i.'
  • ';
    }
    }

    // 末页
    $page .= '
  • »
  • ';
    }

    return $page;
    }
    public function index($p = 1)
    {
    $db = M("shop");

    $data = $db->page($p, 10)->order("id desc")->select();
    $this->assign("data", $data);

    $page = boot_page($db->count(), 10, 5, $p);
    $this->assign("page", $page);

    $this->display();
    }


      {$page}

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

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。