I am building a search engine for a Mysql DB that should hit on keywords and return the member information and diplay it on the webpage. I have the page working for sigle words but I want to be able to check all words client my type in the search box Eg:
Key_Words field or member1 has electronics, computers, toys,
Key_Words field or member2 has planes, trucks, electronics
Key_Words field or member3 has pluming, tools, hardware
user types in where to I find electronics and the php code builds a query that checks each word in the string to see if any words in the fields match and then returnes the members that match
it would return
member1 & member2 but not member3 because member 3 has not words that match the search.
my current code is here:
<?php
$VarSearch_Criteria = ($_POST["TxtSearch"]);
$outputsearch = explode(" ",($VarSearch_Criteria));
$matches = implode("%' OR Key_Words LIKE '",$outputsearch);
if ($VarSearch_Criteria == '') {
echo "Please Enter Search Criteria";
}
else
{
print_r($outputsearch);
$query = ("select * FROM Chamber_Members WHERE Key_Words LIKE '" . $matches . "%'");
$result=mysql_query($query) or die ('Error: '.mysql_error ());
echo($query);
while($row = mysql_fetch_array($result))
{
echo($result);
$logo = trim($row['Business_Image']);
$output .= "<h3>" . $row['Business_Name'] . "</h3>" . "<br />";
$output .= $row['Business_Address'] . "<br />";
$output .= $row['City'] . ", " . $row['State'] . "<br />";
$output .= $row['Zip'] . "<br />";
$output .= "Phone: " . $row['Business_Phone'] . "<br />";
$output .= "Fax: " . $row['Business_Fax'] . "<br />";
?>
as far as I can tell this should to the trick but it is not returning any matching members
Can someone help me to figure out what I am doing wrong.