Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2. // Initiate curl
  3. $ch = curl_init();
  4. // Curl setup w/ url
  5. curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "https://websiteuser3.apache.techcollege.dk/api/city/get_city_list_by_country_id/" . $_POST['destination']]);
  6. // Execute
  7. $result=curl_exec($ch);
  8. // Closing
  9.  
  10. $data = json_decode($result, true);
  11.  
  12. foreach($data as $cityData) {
  13. // Curl setup w/ url
  14. curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "https://websiteuser3.apache.techcollege.dk/api/hotel/get_hotel_list_by_city_id/" . $cityData['id']]);
  15. // Execute
  16. $result=curl_exec($ch);
  17.  
  18. $cityData = json_decode($result, true);
  19.  
  20. foreach($cityData as $cityRows) {
  21. curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "https://websiteuser3.apache.techcollege.dk/api/room/get_room_list_by_hotel_id/" . $cityRows['id']]);
  22.  
  23. $result=curl_exec($ch);
  24.  
  25. $hotelData = json_decode($result, true);
  26.  
  27. foreach($hotelData as $hotelRows) {
  28.  
  29. if($hotelRows['num_persons'] == $_POST['amount']) {
  30.  
  31. curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "https://websiteuser3.apache.techcollege.dk/api/room/get_room_by_id/" . $hotelRows['room_id']]);
  32.  
  33. $result=curl_exec($ch);
  34.  
  35. $roomData = json_decode($result, true);
  36.  
  37. echo '<figure>' .
  38. '<img src="' . $roomData['images'][0]['absolute_filename'] . '">' .
  39. '<h3>' . $hotelRows['room_title'] . '</h3>' .
  40. '<p>' . $hotelRows['hotel_title'] . '</p>';
  41. }
  42. }
  43. }
  44. }
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement