My search should accept "" to create phrases? It allows matching of keywords in " " phrases that is.. When i search "Car Engine", all the records with keywords "This is the Car Engine" would be returned. And not "The Car has an engine"
Now the thing is when i do a search on "Car Engine" , he searches in such a manner
Advanced Search Keyword: \"Car engine\"
Even if there is a match no results were displayed.. Anyone know why?
// Build SQL Query for each keyword entered
foreach ($trimmed_arrayKeyword as $trimmKeyword => $word){
$trimmedKeyword = preg_replace('#\s+#',' ',$trimmedKeyword);
if(strtolower($word )){
$trimmed_arrayKeyword[$trimmKeyword] = "/\b(?<!<)($word)(?!>)\b/i";
}//end if
else $trimmed_arrayKeyword[$trimmKeyword] = '/\b('.preg_quote($word,'/').')\b/i';
$queryKeyword = "SELECT * FROM report WHERE AircraftTailNo REGEXP '[[:<:]]{$word}[[:>:]]' OR DefectInfo REGEXP '[[:<:]]{$word}[[:>:]]' OR Rectifications REGEXP '[[:<:]]{$word}[[:>:]]' OR Comments REGEXP '[[:<:]]{$word}[[:>:]]' OR RelatedDoc REGEXP '[[:<:]]{$word}[[:>:]]'";
$numresultsKeyword =mysql_query ($queryKeyword);
$rowKeyword= mysql_fetch_array ($numresultsKeyword);
$row_num_links_mainKeyword =mysql_num_rows ($numresultsKeyword);
do{
$adid_array[] = $rowKeyword[ 'ReportID' ];
}
while( $rowKeyword= mysql_fetch_array($numresultsKeyword));
} //end foreach
//delete duplicate record id's from the array. To do this we will use array_unique function
$tmparr = array_unique($adid_array);
$i=0;
$newarr = isSet($_POST['Search']) ? $_REQUEST['Search'] : '';
foreach ($tmparr as $v) {
$newarr .= "'" . $v . "',"; //turn newarr into a comma separated string good for an in clause in a query
}
$newarr = substr($newarr,0,strlen($newarr)-1); //remove the trailing comma
// optional search query
$queryAircraftDisplay = "SELECT * from report where 1";
if (!empty($_GET['Keyword'])) {
$queryAircraftDisplay .= " and reportID in ($newarr)";
}
$resultAircraftDisplay = mysql_query($queryAircraftDisplay) or die ("couldn't execute query ".mysql_error());
//bold the resutls
while ($row = mysql_fetch_array($resultAircraftDisplay)) {
$aircraftType = preg_replace($trimmed_arrayKeyword, '<b>\\1</b>' , $row['1']);