Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 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.  
  28. $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";
  29.  
  30. ### 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.  
  33. 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'))){
  34. $master.=' WHERE';
  35. }
  36. if (isset($_GET['type']) && ($_GET['type']!== 'No preference')){
  37. $master.=' type.type_id=$type';
  38. 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'))){
  39. $master.=' AND';
  40. }
  41. }
  42. if (isset($_GET['happy_hour']) && ($_GET['happy_hour'] !=='No preference')){
  43. $master.=' happy_hour.hh_id=$hh';
  44. if((isset($_GET['flavor']) && ($_GET['flavor'] !=='No preference')) || (isset($_GET['area']) && ($_GET['area'] !=='No preference')) || (isset($_GET['rest']) && ($_GET['rest'] !=='No preference'))){
  45. $master.=' AND';
  46. }
  47. }
  48. if (isset($_GET['flavor']) && ($_GET['flavor'] !=='No preference')){
  49. $master.=' flavor.flavor_id=$flavor';
  50. if((isset($_GET['area']) && ($_GET['area'] !=='No preference')) || (isset($_GET['rest']) && ($_GET['rest'] !=='No preference'))){
  51. $master.=' AND';
  52. }
  53. }
  54. if (isset($_GET['area']) && ($_GET['area'] !=='No preference')){
  55. $master.=' area.area_id=$area';
  56. if ((isset($_GET['rest']) && ($_GET['rest'] !=='No preference'))){
  57. $master.=' AND';
  58. }
  59. }
  60. if (isset($_GET['rest']) && ($_GET['rest'] !=='No preference')){
  61. $master.=' rest.rest_id=$rest';
  62. }
  63. $result = $link->query($master);
  64. print "This is the master $master";
  65. if ($result->num_rows > 0) {
  66. 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?</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 "0 results";
  74. }
  75. $conn->close();
  76.  
  77. mysqli_close($link);
  78. ?>
  79.  
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement