Welcome Guest, Not a member yet? Register   Sign In
Multiple Keyword Search
#6

[eluser]JoostV[/eluser]
@Lykos22 : The error is here:
Code:
// set condition for this word
$where_str = '(';

foreach ($search_fields as $field) {
    $where_str .= ' OR ' . $field . ' LIKE \'%' . $word . '%\'';
    // $this->db->or_like($field, $word);
}

// remove first ' OR ' and close parenthesis
$where_str .= substr($where_str, 4) . ')';

When you do $where_str .= substr($where_str, 4) . ')'; you are removing the first parenthesis as well. Try this:
Code:
$where_str = '';
foreach ($search_fields as $field) {
    $where_str .= ' OR ' . $field . ' LIKE \'%' . $word . '%\'';
}
// Wrap in parentheses and remove first OR
$where_str = '(' . ltrim($where_str, ' OR ') . ')';


Messages In This Thread
Multiple Keyword Search - by El Forum - 11-03-2009, 02:34 PM
Multiple Keyword Search - by El Forum - 11-03-2009, 02:49 PM
Multiple Keyword Search - by El Forum - 11-03-2009, 02:54 PM
Multiple Keyword Search - by El Forum - 11-03-2009, 04:12 PM
Multiple Keyword Search - by El Forum - 06-06-2014, 08:55 AM
Multiple Keyword Search - by El Forum - 06-08-2014, 02:05 PM
Multiple Keyword Search - by El Forum - 06-09-2014, 01:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB