Cheers Rick ... I think I nailed it. I've copied my little function
below for anyone else interested.

Am keen on the "saving milliseconds" bit, though (will add it to the
function below before making it live). Any more tips?


Dave

        function parse($what) {

                $what = strtolower($what);
                $what = ltrim($what);
                $what = rtrim($what);

                $wa = explode(" ",$what);
                for ($i=0; $i<= sizeof($wa); $i++) {
                        if (strlen($wa[$i]) !==0) {
                                $j = $i + 1;
                                if ($wa[$i] == "or") {
                                        $output .= " OR search_column
LIKE '%$wa[$j]%' ";
                                        $i++;
                                } elseif ($wa[$i] == "and") {
                                        $output .= " AND search_column
LIKE '%$wa[$j]%' ";
                                        $i++;
                                } elseif ($wa[$i] == "not") {
                                        $output .= " AND search_column
NOT LIKE '%$wa[$j]%' ";
                                        $i++;
                                } else {
                                        $output .= " AND search_column
LIKE '%$wa[$i]%' ";
                                }
                        }
                }
//              strip leading AND from every option
                $output = substr($output, 4, strlen($output)-3);
                $what = $output;
                return $what;
        }


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to