I'm currently using
$terms = explode(" ", $k);
$query = "SELECT * FROM search WHERE ";
foreach ($terms as $each) {
$i++;
if ($i == 1)
$query .= "keywords = '%$each%' ";
else
$query .= "OR keywords LIKE '%$each%' ";
}
// connect
mysql_connect("localhost", "root", "password");
mysql_select_db("search");
$query = mysql_query($query);
$numrows = mysql_num_rows ($query);
if ($numrows > 0) {
while ($row = mysql_fetch_assoc($query)) {
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$keywords = $row['keywords'];
$links = $row['link'];
echo "<h2>$title</h2><p>$description</p>";
}
}
else
echo "No Search Results have been found for \"<b>$k</b>\"";
// disconnect
mysql_close();
?>
this piece of code I learned from a tutorial to begin my search engine. I'll be honest, I don't know any PHP, and understanding what's going on here has been a real struggle.
How do I manipulate this piece of code such that if I search "Swarthmore College" or "Swarthmore", Swarthmore results will show up. I need to make sure that just typing "College" or "swar" or "a" won't trigger the Swarthmore results. But I need common words like "University", "of", and "Chicago" to trigger together for college searches like "University of Chicago." It should also be triggered by abbreviations like "UChicago."
I'm sorry if this is a lot to ask, but I am completely lost. Thank you in advance.