Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 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, ma$
  28.  
  29. print "$master<br />";
  30. if (isset($_GET['type'])&&($_GET['type'])!== 'No preference' || isset($_GET['happy_hour']) && ($_GET['happy_hour']) !=='No $
  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'])!=='$
  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 preferen$
  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$
  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>$
  68. }
  69. echo "</table>";
  70. } else {
  71. echo "0 results. Stop being picky, all alcohol is good alcohol!";
  72. }
  73. $conn->close();
  74.  
  75. mysqli_close($link);
  76. ?>
  77.  
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement