在Codeigniter中获得相同的分页数据

在Codeigniter中获得相同的分页数据

本文介绍了在Codeigniter中获得相同的分页数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CodeIgniter中单击带有以下代码的下一个分页按钮时,我得到的数据相同

I am getting the same data when I am clicking on the next button of pagination in CodeIgniter with the following code

public function view($slug){
    $data['title']=  $slug;
    $data['description']= "None";
    $postdatacount = $this->Constant_model->snippettagscount($slug);
    $checktags= $this->Constant_model->gettags($slug);

   if($checktags>0){

    if ($postdatacount>0) {

        $config = array();
    $config["base_url"] = base_url() ."tags/".$slug;
    $config["total_rows"] = $postdatacount;
    $config["per_page"] = 6;
    $config["uri_segment"] = 2;

    $config['full_tag_open'] = '<ul class="pagination">';
    $config['full_tag_close'] = '</ul>';
    $config['first_link'] = false;
    $config['last_link'] = false;
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['prev_link'] = '&laquo';
    $config['prev_tag_open'] = '<li class="prev">';
    $config['prev_tag_close'] = '</li>';
    $config['next_link'] = '&raquo';
    $config['next_tag_open'] = '<li>';
    $config['next_tag_close'] = '</li>';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';
    $config['cur_tag_open'] = '<li class="active"><a href="#">';
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';

    $this->pagination->initialize($config);

    $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;

    $data["links"] = $this->pagination->create_links();
    $data["title"] = "All Tags";
    $data["description"] = "All Tags";


    $data['snippets_tags'] = $this->Constant_model->get_tags($config["per_page"],$page,$slug);

    $this->snippetfunctions->add_count('tags','tag_name',$slug);

        $this->load->view('view_tag_snippets', $data);
    }else {

        $data["title"] = "No Snippet Found for this Tag";
        $data["description"] = "No Snippet Found for this Tag";
        $data["slug"] =$slug;



        $this->load->view('error_tags',$data);
    }


   }else{

    $this->load->view('404',$data);

   }

}

主要网址是

当我点击在下一个按钮上,将创建以下URL,但不会加载下一个数据,但会在每个下一页上加载相同的数据,并且发生相同的事情。

When I am clicking on Next button following URL is made but not loading the next data but loading the same data and the same thing happens on every next page.

我使用的路由是

$route['tags/(:any)/(:num)'] = 'tags/view/$1/$2';
$route['tags/(:any)'] = 'tags/view/$1';


推荐答案

问题出在配置 $ config [ uri_segment] = 2; ,根据您的路由,页面变量位于第3段。

The problem is with the config $config["uri_segment"] = 2;, according to your routing the page variable is at segment 3.

使用 $ config [ uri_segment] = 3; 而不是 $ config [ uri_segment] = 2; 。还要更改行 $ page =($ this-> uri-> segment(3))吗? $ this-> uri-> segment(3):0;

Use $config["uri_segment"] = 3; instead of $config["uri_segment"] = 2;. Also change the line $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

更多详细信息

这篇关于在Codeigniter中获得相同的分页数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 21:00