Welcome Guest, Not a member yet? Register   Sign In
pagination Problem please help to newbe
#1

[eluser]Emilhse[/eluser]
I got following problem
i try use pagination class when i use it for all records in table it works ok, but when
there is where in query it just getting craizy please help
Code:
function Posters_ads($id){
        
        
        $config['base_url'] = base_url().'/newpage/index/'.$this->uri->segment(3);
        
        
       $q = $this->db->query("SELECT * FROM classified WHERE AccountID = '$id'");
       echo $config['total_rows'] = $q->num_rows();
        $config['per_page'] = '4';
        $config['full_tag_open'] = "<p class ='paginate' >";
        $config['full_tag_close'] = '</p>';
        
        $config['first_link'] = 'First Page';
        $config['last_link'] = 'Last Page';
        
        $this->pagination->initialize($config);
      
      
        $data['pages'] =  self::get_pads($id , 3,$this->uri->segment(4));
        
        echo $this->uri->segment(4);
        echo "<br />";
    
      $this->load->view('home_p',$data);
      
        
    }
     function get_pads($id,$num,$offset)
    {
      
        $this->db->order_by('AdID','desc');
        $q = $this->db->query("SELECT * FROM classified WHERE AccountID = '$id' LIMIT $num OFFSET $offset ");
        return $q->result_array();
        
    }
this is the last i tried

before it i tried this way both of them does not work

pagination shows last page and when you try to navigate it does not show current page

Code:
function Posters_ads($id){
        
        
        $config['base_url'] = base_url().'/home/v_poster_other_ads/'.$this->uri->segment(3);
        
        
        $q = $this->db->query("SELECT * FROM classified WHERE AccountID = '$id'");
       echo $config['total_rows'] = $q->num_rows();
        $config['per_page'] = '4';
        $config['full_tag_open'] = "<p class ='paginate' >";
        $config['full_tag_close'] = '</p>';
        $config['num_links']='5';
        $config['first_link'] = 'First Page';
        $config['last_link'] = 'Last Page';
        
        $this->pagination->initialize($config);
      
      
        $data['pages'] =  self::get_pads($id , 3,$this->uri->segment(4));
    
      $this->load->view('home',$data);
      
        
    }
     function get_pads($id,$num,$offset )
    {
        $this->db->order_by('AdID','desc');
        $this->db->where('AccountID',$id);
        $query = $this->db->get('classified',$num,$offset);
        return $query->result_array();
    }

please help i got really stuck

#2

[eluser]Sanjay Sarvaiya[/eluser]
Hey,

First of all you have to load pagination class.
You forget to initialize uri_segment

Code:
$this->load->library('pagination');
$config['uri_segment'] = 3;
#3

[eluser]Emilhse[/eluser]
thank you very much i will try,
the thing is pagination itself works but it does not show the current page
pagination class is on autoload for me
#4

[eluser]Emilhse[/eluser]
no luck still does not work any ideas more?
#5

[eluser]Sanjay Sarvaiya[/eluser]
In your case uri_segment is 4, Have you tried this?
Code:
$config['uri_segment'] = 4;
#6

[eluser]Emilhse[/eluser]
thank you very much it worked just fine thanks again




Theme © iAndrew 2016 - Forum software by © MyBB