title: MySQLi Full Text Search For Multiple Column Category
body: <p>I want to make mysqli full text search with or without multiple category based on checkbox selection.</p>
  
  <p>Search is based on four category within same column.</p>
  
  <p>Search category are windows, games, tablet, mobile.</p>
  
  <p>When category/multiple category selected through checkbox selection search should be done for selected category only.</p>
  
  <p>Table Structure</p>
  
  <pre><code>id  category   title                date ...
  1   windows    windows7             d1  ...
  2   games      windows games        d2  ...
  3   tablet     windows tablet       d3  ...
  4   mobile     windows mobile       d4  ...
  5   windows    windows8             d5  ...
  6   windows    windows vista        d6  ...
  </code></pre>
  
  <p>checkboxes  for search are</p>
  
  <p>Search in</p>
  
  <pre><code>  &lt;li&gt;&lt;label&gt;&lt;input name="all" type="checkbox" checked="checked" /&gt;All&lt;/label&gt;&lt;/li&gt;
    &lt;li&gt;&lt;label&gt;&lt;input name="windows" type="checkbox" /&gt;Windows OS&lt;/label&gt;&lt;/li&gt;
    &lt;li&gt;&lt;label&gt;&lt;input name="mobile" type="checkbox" /&gt;Windows Mobile&lt;/label&gt;&lt;/li&gt;
    &lt;li&gt;&lt;label&gt;&lt;input name="games" type="checkbox" /&gt;Windows Games&lt;/label&gt;&lt;/li&gt;
    &lt;li&gt;&lt;label&gt;&lt;input name="tablet" type="checkbox" /&gt;Windows Tablet&lt;/label&gt;&lt;/li&gt;
  </code></pre>
  
  <p>Example1: </p>
  
  <pre><code>Search for 'windows' should return result as
  
  windows7
  windows8 
  windows vista
  
  When only checkbox windows is checked
  </code></pre>
  
  <p>Example2: </p>
  
  <pre><code>Search for 'windows' should return result as
  
  windows7
  windows8 
  windows vista
  windows games
  
  When checkbox windows and games are checked.    
  </code></pre>
  
  <p>I have made a query but it is not working at all.</p>
  
  <pre><code>$query = "SELECT * FROM $table WHERE ";
  $query .= "category='' ";
  $query .= "OR category='windows' ";
  $query .= "OR category='games' ";
  $query .= "OR category='mobile' ";
  $query .= "OR category='tablet' ";
  
  $query .= " AND MATCH (title) AGAINST ('+$keyword*' IN BOOLEAN MODE) ORDER by id desc, title desc LIMIT 10";
  </code></pre>
  
  <p>I have also tried like this but not working.</p>
  
  <pre><code>$query = "SELECT * FROM $table WHERE ";
  $query .= "MATCH (category) AGAINST ('' IN BOOLEAN MODE) ";
  $query .= "OR MATCH (category) AGAINST ('windows' IN BOOLEAN MODE) ";
  $query .= "OR MATCH (category) AGAINST ('games' IN BOOLEAN MODE) ";
  $query .= "OR MATCH (category) AGAINST ('mobile' IN BOOLEAN MODE) ";
  $query .= "OR MATCH (category) AGAINST ('tablet' IN BOOLEAN MODE) ";
  
  $query .= " AND MATCH (title) AGAINST ('+$keyword*' IN BOOLEAN MODE) ORDER by id desc, title desc LIMIT 10";
  </code></pre>
  
  <p>Please see why its not working and suggest how search query can be made for no of fields selected.</p>
  
  <p>Thanks.</p>