分页中的链接不起作用 [英] link in pagination does not work
问题描述
我正在尝试进行分页,但我几乎可以理解它,但是当我将一页切换到另一页时,(单击第1页,随后单击第2页)不起作用,但是当我手动进行时有效.这是因为,当我单击浏览器中的链接时,显示以下内容:&page=40
,而我只手动放置了40
.我不知道为什么.
I am trying to make a pagination and I almost get it, but when I change one page to another (click page 1, later click page 2) does not work, but when I do manually it works. That is becouse when I click in the links in my browser show this:&page=40
, and manually I only put the 40
. I do not know why is that.
这是我的控制器
function Test ($value){
if($value =='1'){
$config['per_page'] = 20;
$config['num_links'] = 10;
$config["total_rows"] = $this->db->get('normas')->num_rows();
$data['query'] = $this->db->get('normas', $config['per_page'], $this->uri->segment(4));
$this->pagination->initialize($config);
$data["links"] = $this->pagination->create_links();
$this->load->view('template/general_template/template', $data);
}
}
我的观点
<?php
foreach ($query->result() as $row) {
echo '<p>'. $row->norma.'</p>';
}
echo $links;
?>
请帮助!!,谢谢.
推荐答案
我不得不更改$config['page_query_string']== FALSE
,因为我在TRUE
I had to change $config['page_query_string']== FALSE
becouse I had it in TRUE
$ config [‘page_query_string’] = TRUE;
$config[‘page_query_string’] = TRUE;
默认情况下,分页库假定您使用的是URI细分,并>构造类似以下内容的链接:
By default, the pagination library assume you are using URI Segments, and >constructs your links something like:
http://example.com/index.php/test/page/20 如果您将$ config ['enable_query_strings']设置为TRUE,则将使用查询字符串自动重写链接.也可以显式设置此选项.使用$ config ['page_query_string']设置为TRUE,分页>链接将变为:
http://example.com/index.php/test/page/20 If you have $config['enable_query_strings'] set to TRUE your links will >automatically be re-written using Query Strings. This option can also be >explicitly set. Using $config['page_query_string'] set to TRUE, the pagination >link will become:
http://example.com/index.php ?c = test& m = page& per_page = 20
我在Codeigniter文档中找到了这个 CodeIgniter文档
I found this in the Codeigniter documentation CodeIgniter documentation
这篇关于分页中的链接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!