Guest User

Untitled

a guest
Aug 10th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. require(__DIR__ . "/../includes/config.php");
  4. $places = [];
  5. // ensure proper usage
  6. if (!isset($_GET["geo"]) || strlen($_GET["geo"]) === 0)
  7. {
  8. http_response_code(400);
  9. exit;
  10. }
  11.  
  12. $places = CS50::query("SELECT * FROM places WHERE MATCH(postal_code,place_name,admin_name1,admin_name2,admin_name3) AGAINST (?) LIMIT 50", $_GET["geo"]);
  13.  
  14. // output places as JSON (pretty-printed for debugging convenience)
  15. header("Content-type: application/json");
  16. print(json_encode($places, JSON_PRETTY_PRINT));
  17.  
  18. ?>
Add Comment
Please, Sign In to add comment