Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. $name = NULL;
  2. $floor = NULL;
  3.  
  4. //sprawdza czy podano name i floor i zwraca potrzebne dane
  5. if(isset($_POST['name']) && isset($_POST['floor']))
  6. {
  7. $name = $_POST['name'];
  8. $floor = $_POST['floor'];
  9.  
  10. $dbconn = new DatabaseConnect;
  11. $stmt = $dbconn->prepare("select m.id, b.name, m.floor, m.image, m.image_width, m.image_height, m.image_md5 from maps m left join buildings b on m.building_id = b.id where b.name=? and m.floor=?");
  12. $stmt->bind_param("si",$name,$floor);
  13. $stmt->execute();
  14.  
  15. header('Content-Type: application/json');
  16. return json_encode($stmt->get_result()->fetch_all(MYSQLI_ASSOC));
  17. }
  18.  
  19. //jesli nie podano floor zwraca wszystkie mapki
  20. if(isset($_POST['name']))
  21. {
  22. $name = $_POST['name'];
  23.  
  24. $dbconn = new DatabaseConnect;
  25. $stmt = $dbconn->prepare("select * from maps left join buildings on maps.building_id = buildings.id where buildings.name=?" );
  26. $stmt->bind_param("s",$name);
  27. $stmt->execute();
  28.  
  29. header('Content-Type: application/json');
  30. return json_encode($stmt->get_result()->fetch_all(MYSQLI_ASSOC));
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement