// build an array of word seperators
$search = array(' ' , ', ' , ',' , ' ');
// use word-seperators to create a comma-delimited string of keywords
$kw = str_replace($search, ',' , $_GET['keywords']);
// use new word list in a full text search
$sql = "SELECT * FROM job_post
WHERE MATCH (position, description)
AGAINST (" . $kw . ")"
// OR DOING IT WITHOUT FULL TEXT - BUT WHY????
// make an array of keywords, assumes words seperated by single space
$kw = explode(' ', $_GET{'keyword']);
// use keyword array to build WHERE clause of query string;
$i = 0;
foreach ($kw as $val) {
if ($i>0) { $str .= " OR ";}
$str .= "position LIKE '%" . $val . "%' OR description LIKE '%" . $val . "%'"
$i++;
}
// build query
$sql = "SELECT * FROM job_post
WHERE " . $str;
The full text search will find records with any match to any keyword in either column, but it will also order the results sorted with the highest relevance first.
Without full text you will just get them returned as found, probably defaulting to the primary key order. No ordering according to relevance will occur.