|
本帖最后由 phoenixg 于 2011-7-31 14:42 编辑
控制器代码(/application/controllers/manage/article.php)
PHP复制代码
public function edit()
{
$this->load->model('article_model');
$this->load->view('includes/v_header');
//分页
$count = $this->article_model->count_article_usingcount();
//分页链接设置
//分页不起作用,开发到这里
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/manage/article/edit/';
$config['total_rows'] = $count;
$config['per_page'] = '10';
$config['num_links'] = 10; //当前页码边上放几个链接
$config['first_link'] = '首页';
$config['last_link'] = '尾页';
$config['next_link'] = '下一页';
$config['prev_link'] = '上一页';
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
//查询
$page = & $this->uri->segment(4,0);
echo $page;
$per_page = & $config['per_page'];
echo $per_page;
//要传递给视图的变量
$data['pagelinks'] = $this->pagination->create_links(); //分页链接HTML
$data['article'] = $this->article_model->get_article($page,$per_page);//文章各字段信息
//加载视图
$this->load->view('manage/v_article_edit',$data);
$this->load->view('includes/v_footer');
}
复制代码
模型代码(/application/models/article_model.php)
PHP复制代码
function count_article_usingcount() {
$count = $this->db->count_all_results('embryo9_articles');
return $count;
}
function get_article($page,$per_page)
{
$query = $this->db->query("SELECT `id`,`article_title`,`article_zh`,`testimony_people`,`testimony_date`,`translation_status`
FROM `embryo9_articles`
ORDER BY `id` DESC
LIMIT $page,$per_page;");
$result = $query->result();
return $result;
}
复制代码
症状是:
分页超链接能显示,点击1、2、3。。。分页可以正常显示对应的文章信息,但是点击“下一页”,该链接却永远指向前十条记录,即无论当前页是哪一页,“下一页”都一直指向:http://localhost/ci_volunteers/index.php/manage/article/edit/10
|
|