[eluser]alejandronanez[/eluser]
Hey guys, It's me again... ¬¬
The thing is that my pagination function "misses" the last link, for example.
I got this for my
MODEL
Code:
function get_records($num = 0, $offset = 0)
{
if($num==0 && $offset==0)
{
$query = $this->db->get('AREA_ENSENANZA_NOMBRADO');
if($query->num_rows()>0)
{
foreach ($query->result() as $row):
$data['records'][] = $row;
endforeach;
$data['total_rows'] = $query->num_rows();
}else
{
$data['total_rows'] = 0;
}
}
else
{
$query = $this->db->get('AREA_ENSENANZA_NOMBRADO', $num, $offset);
if($query->num_rows()>0)
{
foreach ($query->result() as $row):
$data['records'][] = $row;
endforeach;
$data['total_rows'] = $query->num_rows();
}else
{
$data['total_rows'] = 0;
}
}
return $data;
}
And I got this for my
CONTROLLER
Code:
function read()
{
$query = $this->ar_en_nom_model->get_records();
if($query['total_rows']>0)
{
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/tesis/index.php/ar_en_nom/index';
$config['total_rows'] = $query['total_rows'];
$config['per_page'] = 15;
$config['num_links'] = 20;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
$query = $this->ar_en_nom_model->get_records($config['per_page'], $this->uri->segment(3));
$data['records'] = $query['records'];
}
$data['main_content'] = 'ar_en_nom_view';
$data['template']['titulo'] = 'Area Enseñanza Nombrado';
//$data['template']['controlador'] = 'ar_en_nom';
$this->load->view('includes/template',$data);
}
And here's my
VIEW
Code:
<h2><?php echo $titulo; ?></h2>
<?php echo anchor('ar_en_nom/load_create','Crear Registros') ?><br /><br />
<?php if($this->session->flashdata('mensaje')) echo $this->session->flashdata('mensaje');
?>
<?php if(isset($records)){; ?>
<table border="1" class="tabla">
<tr>
<th>Editar</th>
<th>Borrar</th>
<th>Código</th>
<th>Descripcion</th>
</tr>
<?php foreach($records as $row): ?>
<tr>
<td><?php echo anchor("ar_en_nom/update/$row->COD_AREA_ENSENANZA_NOMBRADO",'Editar'); ?></td>
<td><?php echo anchor("ar_en_nom/delete/$row->COD_AREA_ENSENANZA_NOMBRADO",'Borrar'); ?></td>
<td><?php echo $row->COD_DESCRIPCION; ?></td>
<td><?php echo $row->DESCRIPCION; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php echo $this->pagination->create_links();?>
<?php }else{ ?>
<h3>No hay registros de <?php echo $titulo; ?> en la base de datos</h3>
<?php } ?>
The thing is that if I have 30 ROWS, my application loads 14 rows on the pagination 'page' #1 , 15 rows on the pagination #2 and misses the last row. ( it only shows < [1][2] > instead of [1][2][3] ).
I don't know what I'm doing wrong.
Please help me!
Bye guys!!!