CodeIgniter Forums

Full Version: Pagination problem : Only even page number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]anggie[/eluser]
I don't know about this, but my pagination links always navigate to even numbers only (0, 2, 4, etc.)
I have checked my config but i'm sure I do everything right way.

Could you help me? Thanks in advance.

El Forum

[eluser]anggie[/eluser]
This is my 'simplified' controller :
Code:
<?
class Dadan extends Controller{
    function Dadan(){
        parent::Controller();
        $this->load->library('pagination');
    }
    function hello(){
        $limit=$this->uri->segment(3);                
        
        if($limit==''){
              $limit=1;
              }
          $limit=($limit-1)*2;
        
        $data['query']= $this->db->get('posting',2,$limit);

        $total_page=$this->db->count_all('posting');
        $config['base_url'] = base_url().'index.php/dadan/hello/';
        $config['full_tag_open'] = '<div class=paging>';
        $config['full_tag_close'] = '</div>';
        $config['uri_segment'] = 3;
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Prev';
        $config['num_links'] = 3;
        $config['total_rows'] = $total_page;
        $config['per_page'] = '2';        
        $this->pagination->initialize($config);
        $data['link']=$this->pagination->create_links();
        $data['total']=$total_page;
    
        $this->load->view('hello',$data);
    }
}
?&gt;

Come on...help me please...

El Forum

[eluser]anggie[/eluser]
Just information, if I change $config['per_page'] to 1, everything goes OK...

El Forum

[eluser]anggie[/eluser]
I more confused now...
If I change per_page to 3, now not even number,but odd number!

&#^*@$^@&$^@*$&...........................&*&*($&@(*&@!$(

El Forum

[eluser]coldautumn[/eluser]

$limit=$this->uri->segment(3);

if($limit==''){
$limit=1;
}
$limit=($limit-1)*2;

$data['query']= $this->db->get('posting',2,$limit);


Why are you doing this, this is causing the display to be even or odd. If uri->segment(3) is empty set 0.Send only $config['per_page'] & uri->segment(3) values to function or get query, where result is generated.

Hope this might solve it.

El Forum

[eluser]anggie[/eluser]
[quote author="coldautumn" date="1220421104"]
$limit=$this->uri->segment(3);

if($limit==''){
$limit=1;
}
$limit=($limit-1)*2;

$data['query']= $this->db->get('posting',2,$limit);


Why are you doing this, this is causing the display to be even or odd. If uri->segment(3) is empty set 0.Send only $config['per_page'] & uri->segment(3) values to function or get query, where result is generated.

Hope this might solve it.[/quote]
Thanks before.
But I cannot understand your answer. I do that for my query (for page offset)...If you don't mind, could you give me your example using pagination class?

El Forum

[eluser]anggie[/eluser]
Wohooo...
Sorryyy....
I just realized 'THAT'.
I just don't understand HOW THE SYSTEM WORKS!NOW I do!
Now I know why there so less of respect with my question...

El Forum

[eluser]Sumon[/eluser]
Have a look http://ellislab.com/forums/viewthread/89891/#453829