![]() |
extending a simple search - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: extending a simple search (/showthread.php?tid=36545) |
extending a simple search - El Forum - 12-05-2010 [eluser]snowstar[/eluser] Hi All, I've been using a simple search on my site for awhile now how-ever i would like to extend it to help limit some of the search results i get back from my queries. I search via first name, lastname or address to get my results currently. My DB has now gotten much larger so i would like to implement multiple word search so i can search by first name, lastname and address for a more define search. My current controller Code: class Search extends Controller { my current model Code: class Search_model extends Model { I've searched around and found a post which best matches what i want http://ellislab.com/forums/viewthread/113868/ how-ever he doesn't actually post how he sorted it. Any help with pointing me in the right direction is much appreciated. Thanks extending a simple search - El Forum - 12-06-2010 [eluser]SPeed_FANat1c[/eluser] You mean you want lets say result to macth first_name AND last_name? If first_name matches but last_name does't then not show in results? I think then you should do qyuery like this: Code: $this->db->like('firstname', $searchdata); I replaced or_like with like. It now should generate query with AND, so it will return when both firstname and lastname match. Did not test it. extending a simple search - El Forum - 12-06-2010 [eluser]snowstar[/eluser] Thanks for the reply, no i mean i want to search for first name, last name and address to get a result. sort of like "First Name Last Name 123 Street " as the search query. sorry i didnt make that one clear. I tried what you suggested but had no luck extending a simple search - El Forum - 12-06-2010 [eluser]SPeed_FANat1c[/eluser] oh, my example is not that good because it uses the same $searchdata for forst name and last name. You want to enter all search data in one field? The more simple way would be to create several input fields - one for first name, another for last name, etc. And then do like this: Code: $this->db->like('firstname', $input_firstname); |