Search & Pagination

#1
[eluser]Vasi[/eluser]
Hi,

I have a form with 3 inputs (1 text, 2 drop-downs). I have no problem performing the search and in displaying the pagination, the problem is in storing my POST values, on which the search query is based.

If I store them in the session, I keep getting the same result (of course) or nothing at all. So the questions is this:

How do I reset the session variables after I complete my search?
Or: If the session doesn't do the trick on storing the POST values, how should I rebuild my search module.

View
Code:
<?php
    $cauta = array(
        'name' => 'cauta',
        );
    $submit = array(
        'name' => 'search_button',
        'value' => 'Cauta'
                );
    $path = 'search';    
?>
<?=form_open($path);?>
<label><strong>Cauta:</strong>
&lt;?=form_input($cauta);?&gt;</label>
<label><strong>Oras:</strong>
&lt;?=$localitati_search?&gt; </label>
<label><strong>Categorie:</strong>
&lt;?=$categorii_search?&gt; </label>
<label>
&lt;?=form_submit($submit)?&gt; </label>
&lt;?=form_close();?&gt;

Controller
Code:
...
if($this->input->post('localitate'))
{
    $search_sess_loc = array(
        'search_loc' => $this->input->post('localitate')
        );
    $this->session->set_userdata($search_sess_loc);
}

if($this->input->post('categorie'))
{
    $search_sess_cat = array(
        'search_cat' => $this->input->post('categorie')
        );
    $this->session->set_userdata($search_sess_cat);
}
    
if ($this->session->userdata('search_loc'))
     $localitate = $this->session->userdata('search_loc');
else
    {
        $localitate = 0;
    }        
if ($this->session->userdata('search_cat'))
    $categorie = $this->session->userdata('search_cat');
else
{
    $categorie = 0;
}
    
if ($this->session->userdata('search_term'))
     $search_term = $this->session->userdata('search_term');
else
{
    $search_term = '';
}    
...


Messages In This Thread
Search & Pagination - by El Forum - 06-17-2010, 08:59 AM
Search & Pagination - by El Forum - 06-17-2010, 09:13 AM
Search & Pagination - by El Forum - 06-17-2010, 10:04 AM
Search & Pagination - by El Forum - 06-17-2010, 11:01 AM
Search & Pagination - by El Forum - 06-17-2010, 02:48 PM
Search & Pagination - by El Forum - 06-18-2010, 01:34 AM
Search & Pagination - by El Forum - 06-18-2010, 02:35 AM
Search & Pagination - by El Forum - 06-18-2010, 03:08 AM
Search & Pagination - by El Forum - 06-18-2010, 06:52 AM
Search & Pagination - by El Forum - 06-19-2010, 04:14 PM
Search & Pagination - by El Forum - 06-20-2010, 07:35 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.