Welcome Guest, Not a member yet? Register   Sign In
Pagination & Searches
#1

[eluser]CinoGenX[/eluser]
Hi @ All,

I have a db with ~500 records. Ive sucessfully setup a page showing all the data using pagination.

Im now looking at adding a search....but there will be alot of search fields so im slightly dreading building it all up and keeping the pagination links working.

Before i start.....Whats the best/easiest way to do this? (Keeping in mind 10+ search fields, pagination page links, maintaining searched text in the form fields after page reloads etc.)

I like the idea of saving the search into db and just passing the search_id in the uri & sessions for data, whats the 'usual' way of doing this. Should i save all the inputs into an array and save that into the DB or....?

Help...

Thanks.
#2

[eluser]alvaroeesti[/eluser]
Using sessions. I have a web search form with all kinds of whistles and blowers, select lists, text fields, checkboxes, etc

I am not using GET, I am using POST

at the controller I go for every of these controllers, say for a controller named Object, a model called resultados_search_M1 and also as you see, sending as parameters whatever has been selected by the user in the search form

Code:
$object = $this->resultados_search_M1->object_handler($this->input->get_post('object', TRUE));

Then at the Model I have a function that handles me that controller

Code:
public function object_handler($object)
{
  if($object)
  {
   $this->session->set_userdata('object', $object);
   return $object;
  }
  elseif($this->session->userdata('object'))
  {
   $object = $this->session->userdata('object');
   return $object;
  }
  else
  {
   $object ="";
   return $object;
  }
  
  
  
}

Then I go and start with the 2 usual queries:

One to get the number of rows that correspond to the search parameters the user has entered, and the other one to get the actual data.

"geographically" these two queries are located above, before the function handlers




Theme © iAndrew 2016 - Forum software by © MyBB