CodeIgniter分页页面链接不工作 [英] CodeIgniter Pagination Page Links Not Working
问题描述
我在我的codeigniter应用程序中使用分页类。分页链接显示很好,即,我假设正确的链接数量例如。 1 2 3 4 5>,并且页面加载了每页指定的条目数量。
I am using the pagination class in my codeigniter application. The pagination links show up fine, ie, I suppose the right number of links eg. 1 2 3 4 5 >, and the page loads up with the amount of entries I specified per page.
错误是当我点击其中一个链接转到下一组条目时,表示无法找到页面。
The error is when I click on one of the links to go to the next set of entries, it says "page cannot be found".
控制器:
public function index()
{
$config["base_url"] = base_url().'tester';
$config["total_rows"] = $this->test_model->count_entries();
$config["per_page"] = 3;
$config['uri_segment'] = 2;
$config["num_links"] = 10;
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$q1=$this->test_model->get_entries($config["per_page"],$page);
$links = $this->pagination->create_links();
}
模型:
public function count_entries() {
$this->db->where('approved', 0);
$this->db->from('tested');
return $this->db->count_all_results();
}
public function get_entries($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->where('approved', 0);
$q = $this->db->get('tested');
$data = $q->result_array();
return $data;
}
页面的URL是 http:// local:8080 / CIAPP /
在我的配置文件中设置为我的base_url,在本地主机:8080 / CIAPP / tester CIAPP是应用程序目录, tester
是我的控制器。
The URL of the page is http://localhost:8080/CIAPP/tester
, with http://localhost:8080/CIAPP/
set as my base_url in my config file. CIAPP is the application directory and tester
is my controller.
我点击任何分页链接到 http:// localhost:8080 / CIAPP / tester / 3
,其中显示找不到页面。
The error occurs when I click on any of the pagination links which goes to url http://localhost:8080/CIAPP/tester/3
which says "page not found".
当我点击链接2的网址是/ 3,当我点击链接3的网址是/ 6。我想这是因为我每页指定了3个。
When I click on link 2 the url is /3, when I click on link 3 the url is /6. I suppose this is because I specified 3 per page.
如何解决这个问题,这样当我点击分页链接,页面加载适当的条目? / p>
How do I fix this so that when I click the pagination links, the pages with the appropriate entries load up?
推荐答案
CIAPP - 应用程序目录
tester- controller class
CIAPP - application directory tester- controller class
如果那么,
base_url tester / function_name';
base_url().'tester/function_name';
这篇关于CodeIgniter分页页面链接不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!