Advertisement
Guest User

Results

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