Welcome Guest, Not a member yet? Register   Sign In
How to make searchbox work with multiple fields
#1

Hi CI lovers
how can i make one search box with multiple fields?
Reply
#2

(This post was last modified: 05-25-2021, 04:39 PM by includebeer.)

Do you mean one text input field to search in multiple columns? If so you can use like() and orLike() in your query.
PHP Code:
  $this->yourModel
        
->like('title'$searchText)
        ->orLike('description'$searchText)
        ->orLike('comment'$searchText); 

I have an example of that in this article: https://includebeer.com/en/blog/how-to-b...r-4-part-5
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB