Php/ MySql 'Advanced Search' Page

后端 未结 5 1932

I\'m working on an \'advanced search\' page on a site where you would enter a keyword such as \'I like apples\' and it can search the database using the following options:

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 15:47

    You could use

    With at least one of the words

    SELECT * FROM myTable WHERE field LIKE '%$keyword%' 
    or field LIKE '%$keyword2%' 
    or field LIKE '%$keyword3%';
    

    Without the word

    SELECT * FROM myTable WHERE field NOT LIKE '%$keyword%';
    

提交回复
热议问题