[英]CodeIgniter 404 error page not found in pagination
I have problem making CodeIgniter pagination when i click on link i get 404 page not found my code in controler is 当我单击链接时出现CodeIgniter分页时出现问题,我未找到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');
} }
i tried diffrent uri segments, but still no result. 我尝试了不同的uri细分市场,但仍然没有结果。 ?
? I am writing code in right way.
我正在以正确的方式编写代码。 my base_url is empty in config file?
我的base_url在配置文件中为空?
in view my code is 鉴于我的代码是
<?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();
?>
As far I understand you can't access your next page pagination? 据我了解,您无法访问下一页分页? So I think it's because of this
$config['base_url']= 'localhost/records';
所以我想是因为这个
$config['base_url']= 'localhost/records';
you should put your complete url(including the controller name and function name), so it should be 您应该输入完整的URL(包括控制器名称和函数名称),因此应该
$config['base_url']= 'localhost/records/index.php/controller_name/function';
and in your uri segment should $this->uri->segment(3)
并且在您的uri段中应该
$this->uri->segment(3)
try may be change uri segment 尝试可能是更改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));
For more follow :- pagination in codeigniter 有关更多信息,请:- 在分码器中分页
基本网址必须是
$config['base_url']= 'records/index';
输入的基本URL必须包含用于获取数据的相同函数,这意味着$ config ['base_url'] ='localhost / project / records / index';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.