title: searching partial words from a database
body: <p>I have a simple mysql search function that searches the titles of entries which I'd like to expand to be able to search against partial words...</p>
  
  <p>For example lets say I search: cancel</p>
  
  <p>currently it will return anything with the word cancel in the title. But ideally it should also return anything with the word cancellation in title.</p>
  
  <p>Here's what I have so far...</p>
  
  <pre><code>function search_title_body($q){
      $q = '+' . $q;
      $q = str_replace(' ', '+', $q);
      $q = "+(".$q.")";
  
      $query = "SELECT *,
                MATCH(title) AGAINST('$q' IN BOOLEAN MODE) AS score
                FROM results
                WHERE (MATCH(title) AGAINST('$q' IN BOOLEAN MODE))
                AND (published = 1)
                ORDER BY score DESC";
  
      $query = $this-&gt;db-&gt;query($query);
  
      $results = array();
  
  
      foreach ($query-&gt;result() as $row){
          $results[] = $row;
      }
  
      return $results;
  } 
  </code></pre>
  
  <p>Could anyone point me in the right direction? Thanks a lot for the help :)</p>