PHP - Paginacion con Codeigniter

 
Vista:
sin imagen de perfil

Paginacion con Codeigniter

Publicado por carla (10 intervenciones) el 04/11/2015 16:46:34
tengo una duda, no se muestra los links para paginar hice todo bien no se que puede estar fallando, trabajo con codeigniter tengo paginas footer,header,menu y contenido(dahsboard) soy principiante por favor ayudenme pego mi codigo de mi modelo, mi controlador y mi vista:

route
-----------------------------------------------------------------------------------------------
1
2
3
4
$route['default_controller'] = 'dashboard';
$route['usuario/(:num)'] = 'usuario/index/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;


MODELO
------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Mymodel extends CI_Model {
 
public function count_usuario() {
$this->db->count_all('usuario');
 
}
public function fetch_usuario($limit,$offset){
$this->db->limit($limit, $offset);
$query = $this->db->get('usuario');
	if ($query->num_rows() > 0) {
	return $query->result();
	}else{
		//en caso que no tenga datos en la tabla
	return $query->result();
	}
}

CONTROLLER
-----------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Usuario extends CI_Controller {
 
	public function index($indice=null)
	{
		$this->load->library('pagination');
		$this->load->model('mymodel');
		$config = array();
		$config['base_url'] = base_url(). 'usuario/';
		$config['total_rows'] = $this->mymodel->count_usuario();
 
     	 	  $config['per_page'] = 2;
     	 	  $config['use_page_numbers'] = TRUE;
     	 	  $config['num_links'] = 20;
     	 	  $config['full_tag_open'] = '<ul>';
      		  $config['full_tag_close'] = '</ul>';
      		  $config['num_tag_open'] = '<li>';
      		  $config['num_tag_close'] = '</li>';
      		  $config['cur_tag_open'] = '<li class="active"><a>';
      		  $config['cur_tag_close'] = '</a></li>';
 
		$dadosi['usuario'] = $this->mymodel->fetch_usuario($config['per_page'], $this->uri->segment(3));
		$this->load->view('includes/html_header');
		$this->load->view('includes/menu');
 
		if ($indice==1) {
			$data['msg']="Usuario cadastro con exito";
			$this->load->view('includes/msg_suceso',$data);
		}elseif ($indice==2) {
 			$data['msg']="No fue posible cadastrar Usuario";
			$this->load->view('includes/msg_error',$data);
		}
		$this->load->view('listar_usuario',$dadosi);
		$this->load->view('includes/html_footer');
	}

VIEW LISTAR_USUARIO
-----------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<div class="col-md-12">
	<table class="table table-striped" >
		<tr>
			<th>ID</th>
			<th>Nombre</th>
			<th>Email</th>
			<th>Nivel</th>
			<th>Estado</th>
			<th></th>
			<th></th>
		</tr>
		<?php foreach($usuario as $row) { ?>
		   <tr>
			<td><?php echo $row->IdUsuario; ?></td>
			<td><?php echo $row->nombre; ?></td>
			<td><?php echo $row->email; ?></td>
			<td><?php echo $row->estado==1?'Activo':'Inactivo'; ?></td>
			<td><?php echo $row->nivel==1?'Administrador':'Usuario'; ?></td>
			<td>
			<a href="<?=base_url('usuario/actualizar/'.$row->IdUsuario) ?>" CLASS="btn btn-primary"      class="btn-group">Actualizar</a>
			<a href="<?=base_url('usuario/eliminar/'.$row->IdUsuario) ?>" CLASS="btn btn-danger"`class="btn-group">Eliminar</a>
			</td>
		   </tr>
		<?php }?>
	</table>
	   <?php echo $this->pagination->create_links(); ?>
</div>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder