좋아, 나는 지난 1 시간 동안이 일을 해왔다. 페이지 수가 정확합니다. 지금 두 페이지가 있어야합니다. 나는 지금 그것을 5로 제한하고 있으며 7 개의 결과를 가지고있다. 그러나 2 페이지를 클릭하면 다른 두 게시물이 표시되지 않습니다. 지금 포럼 URL은 다음과 같습니다 : 포럼/카테고리/2 (포럼 컨트롤러, 카테고리 방법, 카테고리 ID는 2) 페이지는 다음과 같이 생각됩니다 : 포럼/카테고리/2/1 페이지 1 및 포럼/카테고리/2/2 페이지 2 등 그러나, 2 페이지 URL이 내게주는 :CodeIgniter 페이지 매김 - 이상한 행동을하는 페이지 링크
포럼/카테고리/5 ... 어떤 카테고리 ID 5가 없습니다. 하지만 카테고리 ID 2의 두 번째 페이지로 연결되어야합니다! 그래서 나는 확신 할 수 없다. 단지 페이지 당 5를 보여주고 있기 때문에 그것은 5를 보여줄 것인가? 확실하지가 작동하지만 여기 내 다음 코드 방법 :
//count the topics in a certain category id for pagination
public function topic_count($id) {
$this->db->where('cat_id', $id);
$this->db->from('forum_topic');
return $this->db->count_all_results();
}
//get all topics in a certain category
public function get_topics($id, $limit, $start) {
$this->db->distinct();
$this->db->select('t.id, t.title, t.sticky, t.locked, u.username as author, COUNT(p.id) as postcount, (SELECT u.username
FROM forum_post fp
INNER JOIN user u ON fp.author_id = u.user_id
WHERE fp.topic_id = t.id
ORDER BY fp.date DESC
LIMIT 1) as lposter, (SELECT fp.date
FROM forum_post fp
WHERE fp.topic_id = t.id
ORDER BY fp.date DESC
LIMIT 1) as lastdate');
$this->db->from('forum_topic t');
$this->db->join('user u', 'u.user_id = t.author_id', 'inner');
$this->db->join('forum_post p', 'p.topic_id = t.id', 'inner');
$this->db->where('t.cat_id', $id);
$this->db->group_by('t.id, t.title, t.sticky, t.locked, author, lposter, lastdate');
$this->db->order_by('t.sticky desc, p.date desc');
$this->db->limit($limit, $start);
return $this->db->get()->result();
}
내가 직면 한 동일한 문제를 다음 JQuery와에서 처리 :
이보십시오. check http://stackoverflow.com/questions/18025993/pagination-current-link-not-highlighting/32863062#32863062 – vineet