[eluser]Unknown[/eluser]
hi!.This is pagination error:
//this is controller
function cat($id){
//use this for the category page
$id = (int) $this->uri->segment(3);
$cat =$this->MCategories->getCategory($id);
if (!count($cat)){
redirect('kienvang/index','refresh');
}
$data['title'] = "Kien Vang | ". $cat['name'];
if ($cat['parentid']<1){
//show other categories
$data['listing'] = $this->MCategories-> getSubCategories($id);
$data['level'] = 1;
}else{
//show classifieds
$this->load->library('pagination');
$config['base_url'] = site_url('kienvang/cat');
$config['total_rows'] = $this->MClassifieds->getClassifiedsByCategory_count($id);
$config['per_page'] = 2;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
//$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['listing'] = $this->MClassifieds-> getClassifiedsByCategory($config['per_page'],(int) $this->uri->segment(4),$id);
$data['level'] = 2;
}
$data['category'] = $cat;
$data['main'] ='category';
$data['menulist'] =$this->MCategories->getCategoriesMenu();
$this->load->vars($data);
$this->load-> view('template');
}
//model
function getCategory($id){
$data = array();
$options = array('id' => $id);
$Q = $this-> db-> getwhere('categories',$options,1);
if ($Q-> num_rows() > 0){
$data = $Q-> row_array();
}
function getClassifiedsByCategory_count($catid){
$this-> db-> select('id,title,region,created');
$this-> db-> where('category_id', $catid);
$this-> db-> where('status', 'active');
$this-> db-> orderby('id','asc');
return $this->db->count_all_results('classifieds');
}
function getClassifiedsByCategory($limit,$offset,$catid){
$data = array();
$this-> db-> select('id,title,region,created');
$this-> db-> where('category_id', $catid);
$this-> db-> where('status', 'active');
$this-> db-> orderby('id','asc');
$Q = $this-> db->get('classifieds',$limit,$offset);
if ($Q->num_rows()>0){
foreach ($Q->result_array() as $row){
$data[] =$row;
}
}
$Q->free_result();
return $data;
}
///view
<?php
echo "<h2 class='home'>".$category['name']."</h2>";
foreach($listing as $key=>$list){
echo "<div class='post'>";
echo "<h3 class='title'>";
switch($level){
case "1":
echo anchor('kienvang/cat/'.$list['id'],$list['name']);
echo "</h3>";
break;
case "2":
echo anchor('kienvang/classified/'.$list['id'],$list['title']);
echo "</h3>";
echo "<p class='byline'>".$list['created']." | ".$list['region']."</p>";
break;
}
echo "</div>";
}
?>
<?php echo pagination_links(); ?>
error :
from page 2 or 3 ... is disabled.
I wish the you to help.
thank...