We can display results in two ways.
Type 1: Display the document if all the search words present in the document.
Type 2: Display the document if any one of the search words is present.
If you want to perform the Type 1 operation, include the following code snippet in to your program.
//count no of words in the search words and store in a variable
$noofSearchWords=count($searchWords);
$noofSearchWords stores the number of search words. Later after searching search words in key
word table we get results. There we can perform logical AND operation that will display our desired results.
If $noofSearchWords is equal to number of records, the next part of the program gets
executed. Else NO SEARCH RESULT FOUND is displayed.
In the next step, we have to search for words in $searchWords array in the keyword table. The following code snippet
will return you a list of keyids that matched query.
<?php
//implode to an array
$arrWords = implode("' OR keyword='", $searchWords);
//get the key ids from the key table
$query = "select * from keytable where keyword='$arrWords'";
$kResult = mysql_query($query);
?>