zoukankan      html  css  js  c++  java
  • CodeIgniter学习笔记(十三)——CI中的分页

    首先加载分页类

    $this->load->library('pagination');

    然后设置分页属性

    // 每页显示的数量
    $config['page_size'] = 10;
    // 总数据量
    $config['total_rows'] = 200;
    // 设置分页跳转页面的基础地址
    $config['base_url'] = site_url('index.php/user/test');
    // 设置分页显示文字
    $config['first_link'] = '首页';
    $config['next_link'] = '下一页';
    $config['prev_link'] = '上一页';
    $config['last_link'] = '末页';

    初始化分页类

    $this->pagination->initialize($config);

    创建链接并传递给视图

    $data['links'] = $this->pagination->create_links();
    $this->load->view('test', $data);

    通过URL获取偏移量拼装查询

    $offset = (int)$this->load->uri->segment(3);
    $sql = "SELECT * FROM blog_user limit $offset, $page_size";
  • 相关阅读:
    asp.net 2.0 run
    Regular Expression
    assembly
    asp.net loading..
    session
    asp.net performance
    asp.net page order
    interface
    UVA 562 Dividing coins
    UVA 10003 Cutting Sticks
  • 原文地址:https://www.cnblogs.com/iamsupercola/p/4637640.html
Copyright © 2011-2022 走看看