donglu2523 2014-07-28 09:24 采纳率: 100%
浏览 79

Codeigniter分页$ this-> pagination-> create_links()

I have got a problem. $this->pagination->create_links() returns null string.

Here is model :

class Pagination_m extends CI_Model {

public function PaginationHome($count)
{
    $this->load->library('pagination');

    $config['base_url'] = base_url().'home';
    $config['total_rows'] = ceil($count/12);
    $config['per_page'] = 5;
    $config['uri_segment'] = 2;
    $config['full_tag_open'] = '<div style="float: left; width: 960px;">';
    $config['full_tag_close'] = '</div>';
    $this->pagination->initialize($config);
}

}

Controller:

$count = count($this->pictures_m->getAll());

    $this->load->model('pagination_m');
    $this->pagination_m->PaginationHome($count);
    $data['links'] = $this->pagination->create_links();
    var_dump($data['links']);

$count returns 15,

Thanks!

  • 写回答

1条回答 默认 最新

  • dongyuluan7494 2014-07-28 09:40
    关注

    keep your pagination config in your controller would be:-

        $this->load->library('pagination'); 
        $per_page = 50; 
        $data['result'] = $this->model->function_name(); // for display result
        $config['total_rows'] = $this->model->function_name(); // or count rows
        $config['per_page']= $per_page;
        $config['uri_segment'] = 3;
        $config['base_url']= base_url().'/index'; // your url
        $config['suffix'] = '?'.http_build_query($_GET, '', "&"); 
        $this->pagination->initialize($config);
        $data['paginglinks'] = $this->pagination->create_links();   
        $this->load->view('viewname', $data); //your view name
    

    Model:-

       write function which return bunch of data and count rows
    

    view (display your data):-

         <?php echo $paginglinks; ?>
    

    For more :- http://ellislab.com/codeigniter/user-guide/libraries/pagination.html

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动