|
我在首页分页,首页能显示,但点击分页的时候错误:404 Page Not Found
The page you requested was not found.
点击第二页url上面是:
http://localhost/ci/index.php/3
我的代码:
function index()
{
$this->load->library('pagination');
$config['base_url'] = base_url().$this->config->item('index_page');
$config['uri_segment'] = 3;
$config['per_page'] = 3;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';
$config['next_link'] = '>';
$config['prev_link'] = '<';
$fields='gid';
$query=$this->Guestbook->getguestbook($fields);
$config['total_rows'] = $query->num_rows();
$this->pagination->initialize($config);
$query->free_result();
$page = $this->uri->segment(3, 0);
$fields='gid, title, content, pubtime, rednum';
$where=null;
$limit= array('start'=>$config['per_page'],
'end'=>$page
);
$join='fa_user_profile';
$typebegin='id';
$typeend='userid';
$query = $this->Guestbook->getguestbook($fields, $limit);
if ($query->num_rows()>0)
{
$i=1;
foreach ($query->result() as $row)
{
/*** $data['user'][$i]['show_edit_link'] =
($row->role != 'admin' AND $row->role != 'superadmin');
$data['user'][$i]['show_delete_link'] =
($row->role != 'admin' AND $row->role != 'superadmin');**/
// then we just fill the infos
$data['guestbook'][$i]['gid']= $row->gid;
$data['guestbook'][$i]['title']= $row->title;
$data['guestbook'][$i]['content']= $row->content;
$data['guestbook'][$i]['pubtime']= $row->pubtime;
$data['guestbook'][$i]['rednum']= $row->rednum;
$i++;
}
$query->free_result();
}else{
show_error('还没有留言类容!');
}
$data['pagination_links'] = $this->pagination->create_links();
$data['heading'] = '留言';
$this->load->vars($data);
$this->load->view($this->_container);
//$this->output->enable_profiler(TRUE);
} |
|