[eluser]Pascal Kriete[/eluser]
You can chain LIKE clauses using AND and OR. In this case OR is probably more appropriate:
Code:
$field = 'content';
$matches = array(‘love’,‘like’,‘happy’);
// TODO: check if matches has content
$first = array_pop($matches);
$query = "WHERE {$field} LIKE '%{$first}%' ";
foreach($matches as $match)
{
$query .= "OR {$field} LIKE '%{$match}%' ";
}
You may want to consider looking at the active record or_like function. If you don't use active record, remember to sanitize the matches array.