Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT * FROM myTable WHERE field='$keyword';
- SELECT * FROM myTable WHERE field LIKE '%$keyword%';//Let me know if this is the wrong approach
- (field='$keywords') OR ($field='$keywords) (OR)....
- <?php
- $choice = $_POST['choice'];
- $query = $_POST['query'];
- if ($choice == "oneWord") {
- //Not 100% sure what you mean by one word but this is the simplest form
- //This assumes $query = a single word
- $result = mysql_query("SELECT * FROM table WHERE MATCH (field) AGAINST ('{$query}' IN BOOLEAN MODE)");
- } elseif ($choice == "exactWords") {
- $result = mysql_query("SELECT * FROM table WHERE MATCH (field) AGAINST ('"{$query}"' IN BOOLEAN MODE)");
- } elseif ($choice == "atLeastOneWord") {
- //The default with no operators if given multiple words will return rows that contains at least one of the words
- $result = mysql_query("SELECT * FROM table WHERE MATCH (field) AGAINST ('{$query}' IN BOOLEAN MODE)");
- } elseif ($choice == "withoutTheTerm") {
- $result = mysql_query("SELECT * FROM table WHERE MATCH (field) AGAINST ('-{$query}' IN BOOLEAN MODE)");
- }
- ?>
- SELECT * FROM myTable WHERE field LIKE '%$keyword%'
- or field LIKE '%$keyword2%'
- or field LIKE '%$keyword3%';
- SELECT * FROM myTable WHERE field NOT LIKE '%$keyword%';
Add Comment
Please, Sign In to add comment