douqie1884
2015-01-20 04:53
浏览 45
已采纳

CodeIgniter Pagination错误生成下一个链接

I'm Quit New and trying to Make Pagination Inside Codeigniter... I'm to create pagination with one extra argument.. link first argument is for getting ID for database search.. and than create pagination... I've done so far but the next page link is not correct as it should be. please check my code and let me know what's wrong i am doing.

this is model code.. my modelclass name is movie

public function get_movies_by_actor($actor_id,$num=10,$start=0)
{
    $this->db->select(" f.film_id,
                        f.language_id,
                        a.actor_id,
                        f.title,
                        f.description,
                        l.name AS language,
                        c.name AS category,
                        concat(a.first_name, ' ', a.last_name ) AS actor_name
                    ",FALSE);
    $this->db->from('actor AS a');
    $this->db->join('film_actor AS fa', 'fa.actor_id=a.actor_id');
    $this->db->join('film AS f', 'f.film_id=fa.film_id', 'left');
    $this->db->join('language AS l', 'l.language_id=f.language_id', 'left');
    $this->db->join('film_category AS fc', 'f.film_id=fc.film_id', 'left');
    $this->db->join('category AS c', 'c.category_id=fc.category_id', 'left');
    $this->db->where('a.actor_id', $actor_id);
    $this->db->order_by('f.film_id','desc')->limit($start,$num);
    $query = $this->db->get();
    return $query->result();
}

this and controller code. my controller class name is movies

public function actor_movie($actor_id,$start=0)
{
    $data['movies']=$this->movie->get_movies_by_actor($actor_id,$start,10);
    $this->load->library('pagination');
    $config['base_url'] = base_url().'index.php/movies/actor_movie/'.$actor_id.'/';
    $config['total_rows'] = $this->movie->get_total_movies();
    $config['per_page'] = 10;
    $config['display_pages'] = FALSE;
    $config['first_link'] = FALSE;
    $config['last_link'] = FALSE;

    $config['next_tag_open'] = '<li class="next">';
    $config['next_link'] = 'Older Post &rarr;';
    $config['next_tag_close'] = '</li>';

    $config['prev_tag_open'] = '<li class="prev">';
    $config['prev_link'] = '&lt Newer Post';
    $config['prev_tag_close'] = '</li>';

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

    $data['pagination_links'] = $this->pagination->create_links();
    $data['title'] = '$this->pagination->create_links()';

    $this->load->view('header');
    $this->load->view('actor_movies',$data);
    $this->load->view('footer');
}
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujiao3346 2015-01-20 05:59
    已采纳

    just you need to add uri_segment in pagination $config array in Controller Function...

    $config['uri_segment'] = 4;
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题