I always do it this way:

$condition='';
foreach ($phrases as $key=>$val) {
        if (($val != "the") && ($val != "and")) {
                $condition.= "name like '%$val%'  $logic";
        }
}
$condition=substr($condition, 0, strlen($condition) - strlen($logic));
$sql .= $condition;

$length = strlen($sql);
$newlen = $length - 4;
$sql[$newlen].= " order by name";
echo $sql;






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to