帮我在config中创建分页文件

时间:2011-08-19 08:23:11

标签: codeigniter pagination

我想在config文件夹中创建一个分页文件,用于许多页面。

但是,我不知道如何设置$ config []的值,因为它们属于数据。

例如:$ config ['total_rows'] =? $ config ['base_url'] =?

请帮助我!谢谢!

1 个答案:

答案 0 :(得分:1)

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

    $config['base_url'] = base_url().'/site/big/';
    $where = "bot = '2' OR bot = '0'";
    $this->db->where($where);
    $config['total_rows'] = $this->db->count_all_results('visitors');//query here for total rows
    $config['per_page'] = 15;
    //$config['num_links'] = 20;
    $config['full_tag_open'] = '<div id="pagination">';
    $config['full_tag_close'] = '</div>';

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

$this->db->order_by('date', 'DESC');
    $where = "bot = '2' OR bot = '0'";
    $this->db->where($where);
    $this->db->select('id, ip, date, page, host, agent, spammer, country, total, refer');
    $data['records'] = $this->db->get('visitors', $config['per_page'], $this->uri->segment(3));
    $this->table->set_heading('Id', 'IP', 'Date', 'Page', 'Host', 'Agent', 'Spam', 'Country', 'Total', 'Referer');
    $this->load->view('site_view', $data);

基本网址是您的网站网址+控制器/功能 每页是您希望在每个页面上看到的行数