0

So I have already implemented the search.php code. I have tried https://ide50-username.cs50.io/search.php?geo=Cambridge,Massachusetts,US on my code and the staff implementation. My code returns a lot of results like 600 elements, while the staff implementation returns only something like 200 elements. Is that an issue? I have checked all my results, they all contain either Cambridge or massachusetts or both. It seems to be following the same pattern as the staff's one

My code :

<?php

require(__DIR__ . "/../includes/config.php");

// numerically indexed array of places
$places = [];
$arr_places0 = cs50::query("SELECT * FROM places WHERE MATCH (admin_name1, admin_code1, place_name) AGAINST (?)", $_GET["geo"]);
$arr_places1 = CS50::query("SELECT * FROM places WHERE postal_code LIKE ?", $_GET["geo"] . "%");

$arr_places = array_merge($arr_places0, $arr_places1);
for($i = 0, $n = sizeof($arr_places); $i < $n; $i++)
{
    foreach($arr_places[$i] as $key => $element)
    {
        $places[$i][$key] = $element;
    }

}
// output places as JSON (pretty-printed for debugging convenience)
header("Content-type: application/json");
print(json_encode($places, JSON_PRETTY_PRINT));

?>
2
  • How do you check staff's search result? Oct 12 '16 at 18:31
  • something like that mashup.cs50.net/search.php?geo=cambridge What do you mean ?
    – A.Emad
    Oct 13 '16 at 0:27
0

The only way you will get the exact results as the staff's solution is if

  1. The databases are identical (and the data therein).
  2. The indexes are identical.
  3. The select queries are identical.
  4. Definitely other stuff I haven't even thought of.

You could "scrape" staff results and your results and compare them to evaluate the differences, like in text files or spreadsheets. You could load them in side-by-side windows and compare. Or you could verify that your program returns the results you want and expect, and move on. pset8 (and pset7) are far less prescribed than the previous psets. There is no "absolutely correct answer" (which is to say, no check50!), so you are able to exercise some creative freedom. Go for it!

You must log in to answer this question.

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