[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:
<?php
$no = 0;
if($records->result()):
foreach($records->result() as $row):
$no++;
?>
<tr>
<td><?php echo $no; ?></td>
<td><?php echo $row->adminUsername; ?></td>
<td><?php echo $row->adminFullName; ?></td>
<td><?php echo $row->adminEmail; ?></td>
<td><?php echo $row->adminPhone; ?></td>
<td><a >adminID; ?>">Edit</a> <a >adminID; ?>">Delete</a>
<br /><a >adminID; ?>">Change Password</a></td>
</tr>
<?php
endforeach;
else:
?>
<tr>
<td colspan="6"><div id="total_row">No record</div></td>
</tr>
<?php
endif;
?>