I have a mysql table with 3 columns with data for a FAQ search, I want to have a user type a question they want answered and the 3 columns in the table are searched for keywords within the question that appear in any of the columns in the table. And order the results by the row that has the highest number of keyword matches.
I am using the Code Igniter framework. Currently I have a query with FULLTEXT search in my model:
$new_query = 'This is a question';
$sql = "SELECT ques_id, ques_desc FROM ec_questions WHERE MATCH (ques_desc,ques_tags,ques_answer) AGAINST (? IN BOOLEAN MODE) LIMIT 15";
$query = $this->db->query($sql, array($new_query));
return $query->result_array();
But the above doesn’t really seem to return the results I want, help?
Thanks
“Show Create Table” Results:
http://pastebin.com/nKd1JT5n
I don’t think you need
IN BOOLEAN MODEas that adds support for special modifiers+,-etc http://dev.mysql.com/doc/refman/5.5/en//fulltext-boolean.html.Also
implode()doesn’t work directly on stringsstring implode ( string $glue , array $pieces )try
$new_query = 'This is a question';instead of
$new_query = implode(' ', 'This is a question');