Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 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. 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.=' WHERE';
  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. if ($result->num_rows > 0) {
  63. 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>";
  64. // output data of each row
  65. while($row = $result->fetch_assoc()) {
  66. 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>";
  67. }
  68. echo "</table>";
  69. } else {
  70. echo "0 results";
  71. }
  72. $conn->close();
  73.  
  74. mysqli_close($link);
  75. ?>
  76.  
  77. </body>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement