Welcome Guest, Not a member yet? Register   Sign In
Another search pagination problem
#1

[eluser]someone Smile[/eluser]
Hello,
I'm working on some search engine and I would like to have nice pagination, but it looks this is no go with POST type. I've some form in which is entered query for searching and after form is sended, there are some results. The first page of results is normally and work, but if I click on any other page in my pagination there is no results, because the POST input value is nowhere stored. I've already tried to do my search with GET like - to add query in URL, but this is also not possible because CodeIgniter dont't allow some characters which are in urlencode. I was also looking for encoding the query string with base64, but it also looks this is no way because there are some unallowed characters again.

What I have to do instead all of these?

Thanks in advance! :-)
#2

[eluser]Glazz[/eluser]
Save on the database and use for example the id of that search on the pagination..
Save on session using flashdata maybe, this way you can use the keep_flashdata method..
#3

[eluser]someone Smile[/eluser]
That's what I've already done, but it doesn't work.
Code:
$this->form_validation->set_rules('squery','Search Query','required|xss_clean');
  
if ($this->form_validation->run() == FALSE)
{
$this->load->view('cms/theme', $data);
}
else
{
if ($this->input->post('squery') == NULL)
{
  $data['squery'] = $this->session->flashdata('squery');
  $squery = $this->session->flashdata('squery');
}
else
{
  $data['squery'] = $this->input->post('squery');
  $squery = $this->input->post('squery');
  $this->session->set_flashdata('squery', $this->input->post('squery'));
}    

$allresults = $this->Show->article_results($squery);
if ($this->uri->segment(4) == NULL)
{
  $crtpage = 0;
}
$onpage = 10;

$config['base_url'] = site_url('cms/search/');
$config['total_rows'] = $allresults->num_rows();
$config['per_page'] = $onpage;
$config['uri_segment'] = 4;

$this->pagination->initialize($config);

$data['searchnav'] = $this->pagination->create_links();

$data['allresnum'] = $allresults;
$data['articlesearchres'] = $this->Show->article_pag_results($poizvedba, $onpage, $crtpage);

$this->load->view('cms/theme', $data);
#4

[eluser]Glazz[/eluser]
What is not working ?

Is the flashdata being returned with success ?

Remeber that you need to use the keep_flashdata so this way you be able to use the same data on the next page view...


Edit:

Something like this:
Code:
if ($this->input->post('squery') == NULL)
{
$squery = $this->session->flashdata('squery');
$data['squery'] = $squery;
// Keep the flashdata.
$this->session->keep_flashdata('squery');
}
else
{
$squery = $this->input->post('squery');
$data['squery'] = $squery;
$this->session->set_flashdata('squery', $squery));
}
#5

[eluser]someone Smile[/eluser]
I've also added "keep flashdata", but there is nothing different. What could be wrong?
#6

[eluser]Glazz[/eluser]
But what is not working ? The pagination it self or the data on the session ?
#7

[eluser]someone Smile[/eluser]
It looks that will not work, so I will try with base64 and URL. Thank you anyway!
#8

[eluser]Glazz[/eluser]
I have something similiar, and it works fine for me, but if you think you can manage to make it work with base64 go ahead =)




Theme © iAndrew 2016 - Forum software by © MyBB