0

I am having trouble getting search.php to work correctly. I implemented a solution for if the user just searches one term that works great. However, I'm having trouble getting it to work when they search with more than one term (with either a space or , in between words). Here is my code:

$geo = $_GET["geo"];
$broken_up = preg_split("/[\s,]+/", $geo);

end($broken_up);
$last_key = key($broken_up);
reset($broken_up);

// code for if $last_key == 0

else if ($last_key > 0)
{
    $geo = implode(" ", $broken_up);

    $places = CS50::query("SELECT * FROM places WHERE MATCH (postal_code, place_name, admin_name1,
    admin_code1) AGAINST (? IN BOOLEAN MODE)", $geo);
}

If I search, for example, "mary, calif" or "mary,ca", it returns places that have "mary" in their place_name, regardless of the state. In fact, it doesn't return anything from California at all. I've been working on this for quite a while and still can't get it. Any help would be much appreciated!

1 Answer 1

0

Default minimum word length for FULL-TEXT is four characters. I'd recommend going with LIKEs and AND/OR in your SQL query to achieve your goal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .