[eluser]Unknown[/eluser]
hi all, I have this in the view
Code:
<?php $query = $this->db->query("SELECT * FROM noticies WHERE categoria<>'bre' ORDER BY data DESC");?>
<?php foreach($query->result() as $row):?>
<div class="quadrat <?=$row->categoria?>"><b><?php echo utf8_decode($row->titol)?></b>
<p><?php echo utf8_decode($row->cos1)?></p>
<?=anchor('noticies/comentaris/'.$row->id, 'Comentaris');?>
</div>
<?php endforeach; ?>
<div class="quadrat">
<?php echo $this->pagination->create_links()?>
</div>
and that in the controllers
Code:
$config['base_url'] = base_url()."index.php/noticies/index/";
$config['total_rows'] = $this->db->count_all_results('noticies');
$config['per_page'] = '4';
$config['num_links'] = 4;
$config['next_link'] = 'Pàgina següent >';
$config['prev_link'] = '< Pàgina anterior';
$config['next_tag_open'] = '<div style="float:right;">';$config['next_tag_close'] = '</div>';
$config['prev_tag_open'] = '<div style="float:left;">';$config['prev_tag_close'] = ' </div>';
$config['cur_tag_open'] = '<div style="float:left;"><b>';$config['cur_tag_close'] = '</b></div>';
$config['num_tag_open'] = '<div style="float:left;">';$config['num_tag_close'] = '</div>';
$this->pagination->initialize($config);
$noticies['query'] = $this->db->get('noticies', $config['per_page'], (int)$this->uri->segment(3));
$this->load->view('noticies/index', $noticies);
the point is: if I don't do the SQL line, all works fine, but if I do the special query, the HTML result shows all the database entrys (not 4 per_page), and the pagination (of course) doesn't work.
I know I'm doing something wrong, I'm new with CI, can you help me?
lots of thanks