For pset8 in search.php, I cannot get relevant results to show up. I am using match () against () and I really want to only use this. The problem is, for example, when I type in Cincinnati, I get Cincinnati, Iowa as a result. I have been trying to come up with a SQL solution to solve this and I have found a couple relevant questions, but none of the solutions are working.
There are two problems I am running into. First of all, for example, when I type in "Cincinnati", "Cincinnati, IA" is the first result and obviously I would prefer "Cincinnati, OH" to be the first result.
The other problem is when I type in, for example, "Boston, MA", the first results are, "New Boston, MA", "New Boston, NH", "Boston, NY" and more similarly irrelevant results.
Here Is the code.
if(is_numeric($_GET["geo"])){
$places = CS50::query("SELECT * FROM places WHERE postal_code LIKE ?", $_GET["geo"]);
}
else{
// Modify queries
$queries = explode(" ", $_GET["geo"]);
foreach($queries as &$query){
$query = "'+" . $query . "*'";
}
$queries = implode(", ", $queries);
// Get data from MySQL
$places = CS50::query("SELECT * FROM places WHERE
MATCH (place_name, admin_name1, admin_code1)
AGAINST (? IN BOOLEAN MODE)",
$queries);
}
Do you guys have any suggestions? I have tried a lot of alternatives, but this is the best code I have come up with.