Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.04 KB | None | 0 0
  1. <?php
  2. ini_set('error_reporting', E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_STRICT | E_DEPRECATED);
  3. ini_set('display_errors', true);
  4. require_once ("inc/header.php");
  5.  
  6. date_default_timezone_set('Europe/Copenhagen');
  7. $start = new DateTime($_POST['start-date']);
  8. $end = new DateTime($_POST['end-date']);
  9. $activity = $_POST['activity'];
  10. $duration = $start->diff($end);
  11.  
  12. $_SESSION['start'] = $start;
  13. $_SESSION['end'] = $end;
  14. $_SESSION['activity'] = $activity;
  15.  
  16. $result = $dbcon->query("
  17. SELECT DISTINCT
  18. destinations.name AS destination_name
  19. FROM mappings
  20. INNER JOIN packages ON
  21. mappings.packageid = packages.id
  22. INNER JOIN packageimages ON
  23. packages.id = packageimages.packageid
  24. INNER JOIN destinations ON
  25. packages.destinationid = destinations.id
  26. INNER JOIN locals ON
  27. mappings.localid = locals.id
  28. WHERE
  29. packages.activity = '{$activity}' AND
  30. packages.duration > '{$duration->d}'-3 AND
  31. packages.duration < '{$duration->d}'+3
  32. ");
  33.  
  34. if (!$result) {
  35.     $msg = "<div class='alert alert-danger'>The search returned 0 results, try another date range or activity.</div>";
  36. }
  37.  
  38. $destinationslist = $result->fetch_assoc();
  39.  
  40. $result->close();
  41.  
  42. ?>
  43.  
  44. <div class="container" id="results">
  45.     <h1>Search results</h1>
  46.     <div class="row">
  47.         <?php
  48.         if (isset($msg)) {
  49.             echo $msg;
  50.         }
  51.         ?>
  52.  
  53.  
  54.             <?php
  55.                 foreach ($destinationslist as $destination_name) {
  56.                     echo    "<h2>$destination_name</h2>";
  57.                     echo    "<div class='card-deck-wrapper'>
  58.                                <div class='card-deck'>";
  59.                                     $result = $dbcon->query("
  60. SELECT
  61. packages.name AS package_name,
  62. destinations.name AS destination_name,
  63. locals.firstname AS firstname,
  64. locals.lastname AS lastname,
  65. packages.price AS price,
  66. packages.info AS info,
  67. packageimages.imagepath AS packageimage
  68. FROM mappings
  69. INNER JOIN packages ON
  70. mappings.packageid = packages.id
  71. INNER JOIN packageimages ON
  72. packages.id = packageimages.packageid
  73. INNER JOIN destinations ON
  74. packages.destinationid = destinations.id
  75. INNER JOIN locals ON
  76. mappings.localid = locals.id;");
  77.  
  78.  
  79.                     while ($row = $result->fetch_object()){
  80.                     echo "<div class='card'>
  81.                            <img class='card-img-top' src='img/$row->packageimage.png' />
  82.                            <div class='dest-caption'>
  83.                                <h2><span>$row->destination_name</span></h2>
  84.                                <p><span>$row->price DKK</span></p>
  85.                            </div>
  86.                            <div class='card-block'>
  87.                                <h2 class='card-title'>$row->package_name</h2>
  88.                                <p class='card-text'>$row->info</p>
  89.                            </div>
  90.                        </div>";
  91.                         }
  92.                         echo    "</div>
  93.                            </div>";
  94.  
  95.                 }
  96.  
  97.             ?>
  98.  
  99.     </div>
  100. </div>
  101.  
  102. <?php
  103. require_once ("inc/footer.php");
  104. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement