Hi,
I am using the following bit of code to take the keywords input from a form with a field 'keywords'. It works fine, displaying all the matches found (I have omitted the results display code from the snippet) but... the problem I am having is that the loop will produce multiple results of the same record.
For example, if the table contains one record with the title 'Subaru' and the word 'Subaru' is also mentioned in the description my code will return that same record twice ! How do I fix my code so that records will only be displayed once regardless of whether te keywords appear in both the Title and Description fields ?
I hope I have explained what I am trying to do so that it makes sense. Any help would be greatly appreciated. Thanks.
$searchstring = explode(" ",$keywords);
sort($searchstring);
$l = count($searchstring);
for ($i = 0; $i < $l ; $i++) {
$sql6 = "SELECT * FROM auctionitem where title like '%$searchstring[$i]%' or description like '%$searchstring[$i]%' and status = 'current' ORDER BY title ASC ";
$sql_result = mysql_query($sql6,$cid)
or die("Couldn't execute query.");
}