Welcome Guest, Not a member yet? Register   Sign In
Pagination problem
#1

[eluser]orladin[/eluser]
Hi there,

I'm trying to make a pagination with codeigniter.
The problem is
i don't know how to make variable $no to follow the number from the paging.
Right now when i click at any paging it still start with no 1 till 10

thanks

Controller
----------------

Code:
function lists()
{        
    $this->form_validation->set_rules('search_text', 'Search', 'trim|xss_clean|required');
    if ($this->form_validation->run() == FALSE):
        $this->load->library('pagination');
        $this->db->select('*');
        $this->db->from('admin');
        $total_row = $this->db->count_all_results();
        $config['base_url'] = base_url().'/admin/administrator/details/lists/';
        $config['total_rows'] = $total_row;
        $config['per_page'] = 10;
        $config['num_links'] = 3;
        $config['uri_segment'] = 5;
        $config['first_link']      = '<<';
        $config['first_tag_open']  = '<span class="paging">';
        $config['first_tag_close'] = '</span>';                
        $config['last_link']       = '>>';
        $config['last_tag_open']   = '<span class="paging">';
        $config['last_tag_close']  = '</span>';  
        $config['next_link']       = '>';
        $config['next_tag_open']  = '<span class="paging">';
        $config['next_tag_close'] = '</span>';        
        $config['prev_link']       = '<';
        $config['prev_tag_open']  = '<span class="paging">';
        $config['prev_tag_close'] = '</span>';    
        $config['cur_tag_open']    = '<span class="current">';
        $config['cur_tag_close']   = '</span>';
        $config['num_tag_open']    = '<span class="paging">';
        $config['num_tag_close']   = '</span>';
        $this->pagination->initialize($config);
        $this->db->order_by('adminID','desc');
        $data['records'] = $this->db->get('admin', $config['per_page'], $this->uri->segment(5));            
        $data['pagetitle'] = 'Main Menu';
        $data['totalrow'] = $total_row;
        $this->load->view('themes/default/header_frame');        
        $this->load->view('admin/administrator/view_admin', $data);  
    else:
        $this->search_admin();
    endif;                              
}


View
-----------------
Code:
&lt;?php
    $no = 0;
    if($records->result()):    
    foreach($records->result() as $row):  
    $no++;            
    ?&gt;
        <tr>
        <td>&lt;?php echo $no; ?&gt;</td>
        <td>&lt;?php echo $row->adminUsername; ?&gt;</td>
        <td>&lt;?php echo $row->adminFullName; ?&gt;</td>
        <td>&lt;?php echo $row->adminEmail; ?&gt;</td>
        <td>&lt;?php echo $row->adminPhone; ?&gt;</td>                        
        <td><a >adminID; ?&gt;">Edit</a> <a >adminID; ?&gt;">Delete</a>
        <br /><a >adminID; ?&gt;">Change Password</a></td>
        </tr>
    &lt;?php
    endforeach;
    else:                                
    ?&gt;
    <tr>
    <td colspan="6"><div id="total_row">No record</div></td>
    </tr>
    &lt;?php
    endif;
?&gt;
#2

[eluser]Deveron[/eluser]
Hi Orladin,

i answered this kind of question already in this thread:

http://ellislab.com/forums/viewthread/173597/
#3

[eluser]orladin[/eluser]
have try it
but still doesn't work
#4

[eluser]pickupman[/eluser]
Try in your view
Code:
$no = $this->uri->segment(5,0);
#5

[eluser]orladin[/eluser]
excellent pickupman, now it works!
thanks




Theme © iAndrew 2016 - Forum software by © MyBB