search for multiple keywords with php and mysql (where X like)

后端 未结 4 2012
你的背包
你的背包 2020-12-09 13:11

I have a code that dynamically search for data in the database using ajax but I can search for only 1 keyword in a time. I would like to modify it so I can search for multi

4条回答
  •  借酒劲吻你
    2020-12-09 13:38

    Just add an OR clause.

    E.g.

    SELECT * FROM links WHERE name LIKE '%$keyword1%' OR name LIKE '%$keyword2%'
    

    But I strongly recommend you using a parametrized query or other safe library to avoid Sql Injection Attacks

提交回复
热议问题