Guest User

Untitled

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