Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.46 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Filter</title>
  6. <link rel="stylesheet" href="bootstrap-4.0.0-beta/dist/css/bootstrap.min.css" >
  7.  
  8. <link rel="stylesheet" href="css/style.css">
  9. <link href="https://fonts.googleapis.com/css?family=Exo+2" rel="stylesheet">
  10. </head>
  11. <body>
  12. <div id="rooms"></div>
  13.  
  14. <div class="container main-section" id="main">
  15.  
  16. <div class="row">
  17.  
  18. <div class="col-md-4">
  19.  
  20. <h4>Filter by Location </h4>
  21. <input type="checkbox" id="calangute" value="calangute">
  22. <label for="calangute"> Calangute</label><br>
  23. <input type="checkbox" id="baga" value="baga">
  24. <label for="baga"> Baga</label><br>
  25. <input type="checkbox" id="morjim" value="morjim">
  26. <label for="morjim"> Morjim</label><br>
  27. <input type="checkbox" id="candolim" value="candolim">
  28. <label for="candolim"> Candolim</label><br>
  29. <input type="checkbox" id="anjuna" value="anjuna">
  30. <label for="anjuna"> Anjuna</label>
  31.  
  32.  
  33. </div>
  34.  
  35. <div class="col-md-4">
  36. <h4>Filter by Location </h4>
  37.  
  38. <input type="checkbox" id="hotel" value="hotel">
  39. <label for="hotel"> Hotel</label><br>
  40. <input type="checkbox" id="villa" value="villa">
  41. <label for="villa"> Villa</label><br>
  42. <input type="checkbox" id="studio" value="studio">
  43. <label for="studio"> Studio</label><br>
  44. <input type="checkbox" id="resort" value="resort">
  45. <label for="resort"> Resort</label>
  46.  
  47.  
  48. </div>
  49.  
  50. <div class="col-md-4">
  51.  
  52. <h4>Filter by Location </h4>
  53. <input type="checkbox" id="standard" value="standard">
  54. <label for="standard"> Standard</label><br>
  55. <input type="checkbox" id="deluxe" value="deluxe">
  56. <label for="deluxe"> Deluxe</label><br>
  57. <input type="checkbox" id="suit" value="suit">
  58. <label for="suit"> Suit</label><br>
  59.  
  60.  
  61.  
  62. </div>
  63.  
  64.  
  65. </div>
  66. </div>
  67. <div class="display">
  68.  
  69. <!--
  70. <div class="row" >
  71.  
  72.  
  73. <div class="col-md-4">
  74. <img src="img/room1.jpg" alt="room">
  75. </div>
  76. <div class="col-md-6">
  77. <h2>The Taj Aguada</h2>
  78. <p>Villa</p>
  79. <h4 class="text-success">Candolim</h4>
  80.  
  81. </div>
  82. <div class="col-md-2">
  83. <br><br><br><br>
  84. <h4 class="text-primary">Room Type Deluxe</h4>
  85. <h4>Rs : 4000 </h4>
  86. <a href="#"><input type="submit" name="book" value="Book Now" class="btn btn-success"></a>
  87. </div>
  88.  
  89. </div>
  90. -->
  91. </div>
  92. <script src="js/jquery.js"></script>
  93. <script src="bootstrap-4.0.0-beta/dist/js/bootstrap.min.js"></script>
  94. <script src="js/script.js" type="text/javascript"></script>
  95. </body>
  96. </html>
  97.  
  98. $(document).ready(function(){
  99. getAllRooms();
  100. function getAllRooms(){
  101. $.ajax({
  102. url:'action.php',
  103. method: 'POST',
  104. data:{rooms:1},
  105. success:function(response){
  106. $('.display').html(response);
  107. }
  108. });
  109. }
  110.  
  111.  
  112.  
  113. function getRooms(){
  114. var calangute = $('#calangute').val();
  115. var baga = $('#baga').val();
  116. var morjim = $('#morjim').val();
  117. var candolim = $('#candolim').val();
  118. var anjuna = $('#anjuna').val();
  119. var hotel = $('#hotel').val();
  120. var villa = $('#villa').val();
  121. var studio = $('#studio').val();
  122. var resort = $('#resort').val();
  123. var standard = $('#standard').val();
  124. var deluxe = $('#deluxe').val();
  125. var suit = $('#suit').val();
  126. $.ajax({
  127. url: 'action.php',
  128. method: 'POST',
  129. data: {
  130. calangute : calangute,
  131. baga : baga,
  132. morjim : morjim,
  133. candolim : candolim,
  134. anjuna : anjuna,
  135. hotel : hotel,
  136. villa : villa,
  137. studio : studio,
  138. resort : resort,
  139. standard : standard,
  140. deluxe : deluxe,
  141. suit : suit,
  142. },
  143. success:function(response){
  144. $('.display').html(response);
  145. }
  146. });
  147. }
  148.  
  149. $('#calangute').change(function(){
  150. getRooms();
  151. });
  152. $('#baga').change(function(){
  153. getRooms();
  154. });
  155. $('#morjim').change(function(){
  156. getRooms();
  157. });
  158. $('#candolim').change(function(){
  159. getRooms();
  160. });
  161. $('#anjuna').change(function(){
  162. getRooms();
  163. });
  164. $('#hotel').change(function(){
  165. getRooms();
  166. });
  167. $('#villa').change(function(){
  168. getRooms();
  169. });
  170. $('#resort').change(function(){
  171. getRooms();
  172. });
  173. $('#standard').change(function(){
  174. getRooms();
  175. });
  176. $('#deluxe').change(function(){
  177. getRooms();
  178. });
  179. $('#suit').change(function(){
  180. getRooms();
  181. });
  182. $('#studio').change(function(){
  183. getRooms();
  184. });
  185. //
  186.  
  187. });
  188.  
  189. <?php
  190. $conn=mysqli_connect('localhost','cms_user','12345','rooms');
  191.  
  192.  
  193. if (isset($_POST['rooms'])){
  194. if (isset($_POST['rooms'])){
  195. $query_all = "SELECT * FROM rooms ORDER BY rand() ";
  196. }
  197. $query_run = mysqli_query($conn,$query_all);
  198. if (mysqli_num_rows($query_run)>0){
  199. while ($row = mysqli_fetch_array($query_run)){
  200. $room_id = $row['id'];
  201. $room_name = $row['name'];
  202. $location = $row['location'];
  203. $stay_type = $row['stay_type'];
  204. $room_type = ucfirst($row['room_type']);
  205. $image = $row['image'];
  206. $price = $row['price'];
  207.  
  208. echo "
  209. <div class='container rooms'>
  210. <div class='row'>
  211. <div class='col-md-4'>
  212. <img src='img/$image' alt='room' width='100%'>
  213. </div>
  214. <div class='col-md-6'>
  215. <h2>$room_name</h2>
  216. <p>$stay_type</p>
  217. <h4 class='text-success'>$location</h4>
  218.  
  219. </div>
  220. <div class='col-md-2'>
  221. <br><br><br><br>
  222. <h4 class='text-primary'>$room_type</h4>
  223. <h4>Rs : $price </h4>
  224. <a href='#'><input type='submit' name='book' value='Book Now' class='btn btn-success'></a>
  225. </div>
  226. </div></div>
  227. ";
  228. }
  229. } else {
  230. echo "<center><h3>No Properties available</h3></center>";
  231. }
  232.  
  233. }
  234.  
  235. # setting parameters from the post
  236. $calangute = isset($_POST['calangute']) ? $_POST['calangute'] : '';
  237. $baga = isset($_POST['baga']) ? $_POST['baga'] : '';
  238. $morjim = isset($_POST['morjim']) ? $_POST['morjim'] : '';
  239. $candolim = isset($_POST['candolim']) ? $_POST['candolim'] : '';
  240. $anjuna = isset($_POST['anjuna']) ? $_POST['anjuna'] : '';
  241. $hotel = isset($_POST['hotel']) ? $_POST['hotel'] : '';
  242. $villa = isset($_POST['villa']) ? $_POST['villa'] : '';
  243. $studio = isset($_POST['studio']) ? $_POST['studio'] : '';
  244. $resort = isset($_POST['resort']) ? $_POST['resort'] : '';
  245. $standard = isset($_POST['standard']) ? $_POST['standard'] : '';
  246. $deluxe = isset($_POST['deluxe']) ? $_POST['deluxe'] : '';
  247. $suit = isset($_POST['suit']) ? $_POST['suit'] : '';
  248.  
  249. # defaults
  250. $select = "SELECT * FROM rooms";
  251. $where = " WHERE 1 = 1"; # to have a default where that is always true
  252. $order_by = " ORDER BY rand()"; # you can always change the order by this way
  253.  
  254. if ($calangute != '') {
  255. $where .= " AND location = 'calangute'";
  256. }
  257.  
  258. if ($baga != '') {
  259. $where .= " AND location = '$baga'";
  260. }
  261.  
  262. if ($morjim != '') {
  263. $where .= " AND location = '$morjim'";
  264. }
  265. if ($candolim != '') {
  266. $where .= " AND location = '$candolim'";
  267. }
  268.  
  269. if ($anjuna != '') {
  270. $where .= " AND location = '$anjuna'";
  271. }
  272.  
  273. if ($hotel != '') {
  274. $where .= " AND stay_type = '$hotel'";
  275. }
  276. if ($studio != '') {
  277. $where .= " AND stay_type = '$studio'";
  278. }
  279.  
  280. if ($resort != '') {
  281. $where .= " AND stay_type = '$resort'";
  282. }
  283.  
  284. if ($standard != '') {
  285. $where .= " AND room_type = '$standard'";
  286. }
  287. if ($deluxe != '') {
  288. $where .= " AND room_type = '$deluxe'";
  289. }
  290.  
  291. if ($suit != '') {
  292. $where .= " AND room_type = '$suit'";
  293. }
  294.  
  295. if ($villa != '') {
  296. $where .= " AND stay_type = '$villa'";
  297. }
  298.  
  299. $sql = $select . $where . $order_by;
  300.  
  301. $query_run = mysqli_query($conn,$sql);
  302. if (mysqli_num_rows($query_run)>0){
  303. while ($row = mysqli_fetch_array($query_run)){
  304. $room_id = $row['id'];
  305. $room_name = $row['name'];
  306. $location = $row['location'];
  307. $stay_type = $row['stay_type'];
  308. $room_type = ucfirst($row['room_type']);
  309. $image = $row['image'];
  310. $price = $row['price'];
  311.  
  312. echo "
  313. <div class='container rooms'>
  314. <div class='row'>
  315. <div class='col-md-4'>
  316. <img src='img/$image' alt='room' width='100%'>
  317. </div>
  318. <div class='col-md-6'>
  319. <h2>$room_name</h2>
  320. <p>$stay_type</p>
  321. <h4 class='text-success'>$location</h4>
  322.  
  323. </div>
  324. <div class='col-md-2'>
  325. <br><br><br><br>
  326. <h4 class='text-primary'>$room_type</h4>
  327. <h4>Rs : $price </h4>
  328. <a href='#'><input type='submit' name='book' value='Book Now' class='btn btn-success'></a>
  329. </div>
  330. </div></div>
  331. ";
  332.  
  333.  
  334. }
  335. }else {
  336. echo "<center><h3>No Properties available for your search </h3></center>";
  337. }
  338. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement