我不知道我在这里做错了什么,有人可以帮忙,这是我的控制器..我只是想根据分页集显示数据库结果。
function post_paginates($offset = 0){
$this->load->model('Users_model');
$this->load->library('pagination');
$limit = 3;
$config['base_url'] = 'http://localhost/blog_ext/index.php/welcome/post_paginates/';
$config['total_rows'] = $this->Users_model->totalcountPost();
$config['per_page'] = $limit;
$config['num_links'] = 2;
$config['uri_segment'] = 4;
$config['page_query_string']=true;
$config['query_string_segment'] = 'pageno';
$this->pagination->initialize($config);
$data['offset'] = $offset;
$posts = $this->Users_model->get_post($limit, $offset);
$data = array(
'posts' => $posts,
'pages' => $this->pagination->create_links()
);
$this->load->view('post_paginates', $data);
}
这是我的模特
function get_post($limit, $offset){
$query = $this->db->get('NEWS', $limit, $offset);
return $query->result();
}
这是视图
<div id="posts">
<?php
if(isset($posts)){
foreach ($posts as $titles) {
echo $titles->HEADLINE;
echo "<br>";
}
}
?>
</div>
<div id="pages">
<?php echo $pages;?>
</div>
提前感谢..: - )
答案 0 :(得分:0)
使用
$offset = $this->input->get('pageno');
为你的抵消。