我在codeigniter中为我的项目使用分页类,并且由于某种原因它无法正常工作。它只显示我的db和我的“$ config [per_page] = 3”的前三个结果,我的数据库中有20个项目。
这是我的控制器:
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/ci/admin/prod/viewprod';
$config['total_rows'] = $this->db->get('retail_prod')->num_rows();
$config['uri_segment'] = 5;
$config['per_page'] = 3;
$config['num_links'] = 5;
$this->pagination->initialize($config);
$data['records'] = $this->db->get('retail_prod', $config['per_page'], $this->uri->segment(5));
以下是我的观点:
<?php
echo $this->table->generate($records);
echo $this->pagination->create_links();
?>
BTW:我还没有使用路线。
答案 0 :(得分:0)
使用此代码显示分页
$config['first_tag_open'] = $config['last_tag_open']= $config['next_tag_open']= $config['prev_tag_open'] = $config['num_tag_open'] = '<li>';
$config['first_tag_close'] = $config['last_tag_close']= $config['next_tag_close']= $config['prev_tag_close'] = $config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li><span><b>";
$config['cur_tag_close'] = "</b></span></li>";
另外,在视图中,使用如下代码:
<div class="pagination">
<ul>
{$pagination->create_links()}
</ul>
</div>