Welcome Guest, Not a member yet? Register   Sign In
pagination problem
#11

[eluser]Zeeshan Rasool[/eluser]
well this might help you,

Code:
[color=blue]TO SHOW THE COMBO, SO THAT WE CAN CHANGE PER PAGE LISTINGS[/color]

echo form_open('admin/action',$att);
echo "Result  ". $first ." - ".$last ."  of  ".$total."  ";
$options = array(
            '9'      => '9',
            '18'      => '18',
            '27'      => '27',
            '36'      => '36',
            '45'      => '45',
            );
    
$value = 1;
$js = 'onchange="[removed]ShowItem('.$value.')"';
echo form_dropdown('no_r', $options,$max_record,$js);
echo form_close();

SHOW ITEM JAVASCRIPT FUNCTION

function ShowItem(value)
{
    document.frmRecordsPerPage.submit();
}


IN BOTTOM OF THE VIEW USING PAGINATION LIBRARY WE PRINT THE BUTTONS

$config['next_link'] = '<img src="'.base_url().'resources/images/next_button.jpg" alt="" title="" border="0" />';//'Next' Button;
$config['prev_link'] = '<img src="'.base_url().'resources/images/prev_button.jpg" alt="" title="" border="0" />';//'Previous' Button;
$this->pagination->initialize($config);
echo $this->pagination->create_links();


THIS IS CONTROLLER

        $result_p_page = 20;
        if($order=='')
            $order_by=0;
        else
        $order_by=$order;
        if($this->input->post('no_r')!='')
        {
            $result_p_page=$this->input->post('no_r');
        }
        elseif($this->uri->segment(3)!='')
        {
            if($this->uri->segment(3)=='')
            {
                $result_p_page = 20;
            }
            else
            {
                $result_p_page=$this->uri->segment(3);
            }
        }
        if($num_page!=0&&$value!=0)
        {
            $data['num']=$num_page;
            $data['value']=$value;
        }
        elseif($this->input->post('no_r')!=0)
        {
            $data['num']=0;
            $data['value']=$this->input->post('no_r');
        }
        else
        {
            $data['num']=0;
            $data['value']=$result_p_page;
        }  
        
  
        $config['base_url'] = base_url().'/..your address.../'.$result_p_page;
        $config['total_rows'] = $query;
        
        if($num_page==''&& $value=='')
        {
            $config['per_page'] = $result_p_page;
        }
        else
        {
            $config['per_page']=$value;
        }
        $this->pagination->initialize($config);
        
        /// YOU QUERY HERE
    
        $i=0;
        foreach($data['listing_data'] as $item)
        {
            $i++;
        }
        if($num_page=='')
        {
            $start=((sizeof($data['listing_data']))!=0?1:0);
            $data['first']=$start; $data['last']=$i;
        }
        else
        {
            $data['first']=1+$num_page;$data['last']=$num_page+$i;
        }
        $data['max_record']=$result_p_page;
    
        $data['total_rec']=$query;

/// HERE LOAD YOUR VIEW

Cheers....
#12

[eluser]aataqwa[/eluser]
Quote:I see, so maybe I didn’t understand what you meant by “the number in the url”. I thought you were referring to $config[‘uri_segment’] = 3;
There I was specifying 3 rows per page. I don’t see anywhwere to specify the offset, which I assume would start at 0 then get bumped up by 3 each time a new page is retrieved.

if your record > 3 mybe yau pagnation display.
or
Code:
$config[‘uri_segment’] = 4;
#13

[eluser]genny[/eluser]
I'm afraid I don't understand. I was working with 9 records, so I had specified 3 pages with 3 records on each page.




Theme © iAndrew 2016 - Forum software by © MyBB