[eluser]Andre Dublin[/eluser]
Hello, I'm new to codeigniter and followed a few tuts to help me learn pagination. My problem is that I get a 404 error when I click any of the paginated links???
Here is my controller function
Code:
public function index() {
$data = array();
$config['base_url'] = base_url() . 'index.php/registry/';
$config['total_rows'] = $this->registry_model->count_records();
$config['per_page'] = 5;
$config['num_links'] = 5;
$config['uri_segment'] = 3;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
if ($q = $this->registry_model->get_registry($config['per_page'], $page)) {
$data['registry'] = $q;
} else {
return false;
}
$data['title'] = "Events";
$data['main'] = "registry_view";
$data['links'] = $this->pagination->create_links();
$this->load->view('template', $data);
}
Here is my model function
Code:
//count records
public function count_records() {
return $this->db->count_all('Registries');
}
//read registry
public function get_registry($limit, $start) {
$this->db->limit($limit, $start);
$q = $this->db->get('Registries');
if ($q->num_rows() > 0) {
return $q->result();
} else {
return false;
}
}
And the view
Code:
<h1>Add Event</h1>
<?php
echo form_open('registry/create');
echo form_label('Add Event Name', 'registry_name');
echo form_input('registry_name', ' ', 'id="add-event"');
echo form_submit('submit', 'ADD EVENT', 'id="add"');
echo form_close();
?>
<div class="errors">
<?php echo validation_errors(); ?>
</div>
<hr />
<table>
<thead>
<tr>
<th>Events</th>
</tr>
</thead>
<?php if (isset($registry)) : foreach ($registry as $row) : ?>
<tr>
<td><?php echo $row->Registry_Name; ?></td>
<td><?php echo anchor('page/index/' . $row->Registry_ID, 'view'); ?></td>
<td>
<?php
echo form_open("registry/update/$row->Registry_ID");
echo form_label('Update Event Name', 'registry_name');
echo form_input('registry_name', ' ', 'class="update-event"');
echo form_submit('submit', 'UPDATE', 'class="update"');
echo form_close();
?>
</td>
<?php endforeach; ?>
<?php else : ?>
<td>No Events Found</td>
<?php endif; ?>
</tr>
</table>
<?php echo $links; ?>
Now I've read some posts here and at stackoverflow and maybe its got to do with my uri->segment, but I've tried different locations in the uri and no luck, also I've read about the routes file might have something to do with this, but I'm lost there.
Please help, and thanks!