Welcome Guest, Not a member yet? Register   Sign In
Searching multiple tables - fields
#6

I only focussed on the logic for searching in your database, not on the form you provide your users with. I assumed that you already managed to do that part yourself.

The 2 examples I shared:
PHP Code:
$data['city'] = 'New York';  //example of city in your search box
$data['category'] = 15;    //example of category_id in your search box 

were just meant to be able to test the model function, with query builder commands inside it.
In real life, $data['city'], $data['category'] and $data['name'] must get their values from your form.
There is no need for IF statements in your controller. You collect all values in $this->input->post(), put them in the $data array, and pass that to the model. The model function I wrote, detects which search variables have a value, and which haven't.
Reply


Messages In This Thread
Searching multiple tables - fields - by demyr - 10-16-2019, 02:41 AM
RE: Searching multiple tables - fields - by demyr - 10-16-2019, 01:24 PM
RE: Searching multiple tables - fields - by demyr - 10-20-2019, 11:11 AM
RE: Searching multiple tables - fields - by Wouter60 - 10-20-2019, 10:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB