Guest User

Untitled

a guest
Nov 29th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Results</title>
  4. </head>
  5. <body>
  6. <style>
  7. body {background-image: url("margarita cookies.jpg")}
  8. table, th, td {
  9. border: 1px solid black;
  10. background-color:#e6ffcc;
  11. padding: 10px;
  12. }
  13. </style>
  14.  
  15. <body>
  16. <h1>TESTS</h1>
  17. <?php
  18. $host="localhost";
  19. $username="alcohaul";
  20. $password="drunk";
  21. $database="alcohaul";
  22. $link= mysqli_connect($host,$username,$password,$database);
  23. $type = $_GET['type'];
  24. $hh = $_GET['happy_hour'];
  25. $flavor = $_GET['flavor'];
  26. $area = $_GET['area'];
  27. $rest = $_GET['rest'];
  28.  
  29. $master = "SELECT master.master_id, rest.rest, marg.marg, area.area, flavor.flavor, type.type, happy_hour.hh FROM master INNER JOIN marg ON master.marg_id=marg.marg_id INNER JOIN rest ON master.rest_id=rest.rest_id INNER JOIN area ON master.area_id=area.area_id INNER JOIN flavor ON master.flavor_id=flavor.flavor_id INNER JOIN type on master.type_id=type.type_id INNER JOIN happy_hour on master.hh_id=happy_hour.hh_id";
  30.  
  31. if ((isset($_GET['type']) && $_GET['type'] !== 'No preference') ||
  32. (isset($_GET['happy_hour']) && $_GET['happy_hour'] !=='No preference') ||
  33. (isset($_GET['flavor']) && $_GET['flavor'] !== 'No preference') ||
  34. (isset($_GET['area']) && $_GET['area'] !== 'No preference') ||
  35. (isset($_GET['rest']) && $_GET['rest'] !== 'No preference')) {
  36. $master.=" WHERE";
  37. }
  38. if (isset($_GET['type']) && $_GET['type'] !== 'No preference') {
  39. $master.=" type.type_id=$type";
  40. if ((isset($_GET['happy_hour']) && $_GET['happy_hour'] !=='No preference') ||
  41. (isset($_GET['flavor']) && $_GET['flavor'] !=='No preference') ||
  42. (isset($_GET['area']) && $_GET['area'] !== 'No preference') ||
  43. (isset($_GET['rest']) && $_GET['rest'] !== 'No preference')) {
  44. $master.=" AND";
  45. }
  46. }
  47. if (isset($_GET['happy_hour']) && $_GET['happy_hour'] !=='No preference'){
  48. $master.=" happy_hour.hh_id=$hh";
  49. if ((isset($_GET['flavor']) && $_GET['flavor'] !== 'No preference') ||
  50. (isset($_GET['area']) && $_GET['area'] !== 'No preference') ||
  51. (isset($_GET['rest']) && $_GET['rest'] !== 'No preference')) {
  52. $master.=" AND";
  53. }
  54. }
  55. if (isset($_GET['flavor']) && $_GET['flavor'] !== 'No preference'){
  56. $master.=" flavor.flavor_id=$flavor";
  57. if ((isset($_GET['area']) && $_GET['area'] !== 'No preference') ||
  58. (isset($_GET['rest']) && $_GET['rest'] !== 'No preference')){
  59. $master.=" AND";
  60. }
  61. }
  62. if (isset($_GET['area']) && $_GET['area'] !=='No preference'){
  63. $master.=" area.area_id=$area";
  64. if (isset($_GET['rest']) && $_GET['rest'] !== 'No preference'){
  65. $master.=" AND";
  66. }
  67. }
  68. if (isset($_GET['rest']) && $_GET['rest'] !== 'No preference'){
  69. $master.=" rest.rest_id=$rest";
  70. }
  71. $master.=" ORDER BY rest.rest, marg.marg";
  72. $result = $link->query($master);
  73.  
  74. if ($result->num_rows > 0) {
  75. echo "<table><tr><th>Restaurant</th><th>Margarita Name</th><th>Area of Austin</th><th>Flavor</th><th>Consistency</th><th>Happy Hour Availability</th></tr>";
  76. // output data of each row
  77. while($row = $result->fetch_assoc()) {
  78. echo "<tr><td>".$row["rest"]."</td><td>".$row["marg"]."</td><td>".$row["area"]."</td><td>".$row["flavor"]."</td><td>".$row["type"]."</td><td>".$row["hh"]."</td></tr>";
  79.  
  80. }
  81. echo "</table>";
  82. } else {
  83. echo "0 results. Stop being picky, all alcohol is good alcohol!";
  84. }
  85. $conn->close();
  86.  
  87. mysqli_close($link);
  88. ?>
  89.  
  90. </body>
  91. </html>
Add Comment
Please, Sign In to add comment