I have a PHP keyword search script that searches a MySQL database and then displays the results. Currently, the script finds results based on a single keyword attached to a field in a MySQL database.
My question is; how can I attach multiple keywords to one field and return results if one or more of those keywords is matched in the users query?
Can I define the keywords in my database and separate them with commas? e.g. this, would, be, in, the, field
<?php
mysql_connect("localhost","username","password");
mysql_select_db("database");
if(!empty($_GET['q'])){
$query=mysql_real_escape_string(trim($_GET['q']));
$searchSQL="SELECT * FROM questions WHERE `keywords` LIKE '%{$query}%' LIMIT 1";
$searchResult=mysql_query($searchSQL);
while($row=mysql_fetch_assoc($searchResult)){
$results[]="{$row['result']}";
}
echo implode($results);
}
?>