[eluser]gazza7364[/eluser]
I've a problem with pagination, If I set the $input as a static value eg Dixons Wood the pagination works correctly. If I set the value as the post value from a submitted form, the pagination shows the first page correctly, but when I click on say page2 or whatever link, I start start getting all the records from the database. I ran this with
this with profiler enabled and I get the following results
This is for the first page
SELECT COUNT(*) AS `numrows`
FROM (`photos`)
WHERE `subject` = 'Dixons Wood'
SELECT `photo_id`, `subject`, `photo_album`, `orientation`, `thumbpath`, `imagename`
FROM (`photos`)
WHERE `subject` = 'Dixons Wood'
ORDER BY `orientation`
LIMIT 5
When I click a link on the pagination it shows the following:-
SELECT COUNT(*) AS `numrows`
FROM (`photos`)
WHERE `subject` = 0
SELECT `photo_id`, `subject`, `photo_album`, `orientation`, `thumbpath`, `imagename`
FROM (`photos`)
WHERE `subject` = 0
ORDER BY `orientation`
LIMIT 5, 5
As you can see the pagination loses the subject criteria.
Like I said if I put a static value into the $input variable everything works.
I think I see what's happening, that when you click a pagination link, it runs through the code again, but thist time their is no post value.
How do I fix?
This is my controller.
Code:
function multiedit() {
$input = $this->input->post('subject');
echo $input;//for testing
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/photos/multiedit';
//$config['total_rows'] = $this->db->get('photos')->num_rows();
$config['total_rows'] = $this->photo_model->mycount($input);
$config['per_page'] = 5;
$config['num_links'] = 3;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['records'] = $this->photo_model->get_subject($input, $config['per_page'], $this->uri->segment(3));
$this->load->view('photos/multi-edit',$data);
}
Also if I use
Code:
$input = trim($this->input->post('subject'));
I get no results if I click a page link.