Guest User

Untitled

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