Hi,
Made a little change to the seach function so it will search for multiple keywords, e.g. if you put in "blue red" into the search box it will find articles with "blue", articles with "red" and articles with both "blue" and "red" in it, and not exact phrase like the default.
Might be useful for some of you (its live on my site (link in sig) if you want to testdrive first):
// SEARCH ENGINE
function search() {
$search_query = clean($_POST['search_query']);
$search_query_var = "%".$search_query."%";
echo "". l(search_results) ."
";
if (strlen($search_query) < 3) {
echo "". l(charerror) ."
";
} else {
// Matt 11/3/06 13:24 - build up the SQL query so we can use multiple keywords
$keywords = explode(" ",$search_query);
$query = "SELECT * FROM " .s('prefix'). "articles WHERE ";
if (count($keywords) >= 2) {
for ($i=0;$i $query = $query . " (title LIKE '%$keywords[$i]%' || text LIKE '%$keywords[$i]%') ||";
}
$j = count($keywords)-1;
$query = $query . " (title LIKE '%$keywords[$j]%' || text LIKE '%$keywords[$j]%')";
} else {
$query = $query . " (title LIKE '%$keywords[0]%' || text LIKE '%$keywords[0]%')";
}
$query = $query . " AND position <> 2 AND published = 1 ORDER BY id DESC";
// ttaM
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$num++;
$date = date(s('date_format'), strtotime($r['date']));
echo "" .$r['title']. "
" . $date. "
";
}
if ($num == "") { echo "". l('noresults') ." " . $search_query . ".
";
$num = "0";
} else { echo "
" . $num . " ". l('resultsfound') ." " . $search_query . ".
"; }}
echo "
". l('backhome') ."
";
}For those interested, this just replaces the one line of code where the SQL query was generated. All this does is break the query into an array, then build up a new SQL query with multiple LIKE bits.
Oh and I changed the minimum characters to anything less than 3 because there are a load of 3 lettered acronyms like SQL, ASP, JSP, PHP etc etc that I want people to be able to search by

Matt