2014-09-11 114 views
0

没有发现我有问题使CodeIgniter的分页当我点击链接打开我得到的404页没有发现 我在CONTROLER代码CodeIgnier 404错误页面分页

class Records extends CI_Controller 
{ 
    public function index() 
    { 
     $this->load->library('pagination'); 
     $config['base_url']= 'localhost/records'; 
     $config['total_rows']= $this->db->get('pages')->num_rows; 
     $config['per_page']= 2; 
     $config['num_links']= 5; 
     $this->pagination->initialize($config); 
     $data['query'] = $this->db->get('pages',$config['per_page'],$this->uri->segment(2)); 



     $this->load->view('view_header'); 
     $this->load->view('includes/nav_home'); 
     $this->load->view('view_list', $data); 
     $this->load->view('view_footer'); 

}

我想指出错误的URI细分,但仍然没有结果。 ?我以正确的方式编写代码。我的base_url在配置文件中是空的?

鉴于我的代码是

<?php 
echo $this->session->flashdata('item'); 
echo '<h4>Lista podataka</h4>'; 

foreach ($query->result() as $q): 

?> 
<a href="/z/update/grab/<?php echo $q->id;?>/<?php echo $q->info; ?>"><?php echo $q->info . br() . br()?></a> 
<?php 
endforeach; 

echo $this->pagination->create_links(); 
?> 

请其非常重要的

回答

1

据我了解您无法访问您的下一个页面分页?所以,我认为这是因为这个$config['base_url']= 'localhost/records';

你应该把你的完整URL(包括控制器名和函数名),所以它应该是

$config['base_url']= 'localhost/records/index.php/controller_name/function';

,并在你的URI段应$this->uri->segment(3)

+0

它的问题,因为我把分页索引()函数,我创建单独的功能,它的工作原理! – 2014-09-11 08:54:13

+0

你应该把正确的base_url,尝试改变你的代码,并告诉我,如果你仍然有错误 – CodeSlayer 2014-09-11 08:58:39

+0

我做了这个和它的工作功能页面() {this-> load-> library(s) '分页'); $ config ['base_url'] ='http:// localhost/z/records/page'; $ config ['total_rows'] = $ this-> db-> get('pages') - > num_rows; $ config ['per_page'] = 2; $ config ['num_links'] = 5; $ this-> pagination-> initialize($ config); $ this-> load-> model('Data'); ($ 3)); $ data ['query'] = $ this-> Data-> data_pagination($ config ['per_page'],$ this-> uri-> segment(3)); } – 2014-09-11 09:33:39

0

尝试或许会改变URI段

$this->load->library('pagination'); 
    $config['base_url']= base_url().'/records/index'; 
    $config['total_rows']= $this->db->get('pages')->num_rows; 
    $config['uri_segment'] = 3; 
    $config['per_page']= 2; 
    $config['num_links']= 5; 
    $this->pagination->initialize($config); 
    $data['query'] = $this->db->get('pages',$config['per_page'],$this->uri->segment(3)); 

更多后续: - pagination in codeigniter

+0

其问题,因为我把分页索引()函数,我创建了单独的功能,它的工作原理! – 2014-09-11 08:53:47

+0

不是你需要使用正确的基址的功能问题 – 2014-09-11 08:54:46

+0

是的,也许我应该把盈亏指数!这可能是错误 – 2014-09-11 09:38:55

0

基地址必须是

$config['base_url']= 'records/index'; 
0

基URL中必须包含被用于获取数据的相同功能 它意味着$配置[ 'BASE_URL'] ='本地主机/项目/记录/索引';