Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Results</title>
- </head>
- <body>
- <style>
- body {background-image: url("margarita cookies.jpg")}
- table, th, td {
- border: 1px solid black;
- }
- </style>
- <body>
- <h1>TESTS</h1>
- <?php
- $host="localhost";
- $username="alcohaul";
- $password="drunk";
- $database="alcohaul";
- $link= mysqli_connect($host,$username,$password,$database);
- $type = $_GET['type'];
- $hh = $_GET['happy_hour'];
- $flavor = $_GET['flavor'];
- $area = $_GET['area'];
- $rest = $_GET['rest'];
- print "<p> type = $type, happy hour = $hh, flavor = $flavor, area = $area, Restaurant Name = $rest</p>";
- $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";
- print "$master"
- if (isset($_GET['type'])&&($_GET['type'])!== 'No preference' || isset($_GET['happy_hour']) && ($_GET['flavor']) !=='No pref$
- $master.=' AND';
- }
- if (isset($_GET['type']) && ($_GET['type']!== 'No preference')){
- $master.=' type.type_id=$type';
- }
- if (isset($_GET['happy_hour']) && ($_GET['happy_hour'] !=='No preference')){
- $master.=' happy_hour.hh_id=$hh';
- }
- if (isset($_GET['flavor']) && ($_GET['flavor'] !=='No preference')){
- $master.=' flavor.flavor_id=$flavor';
- }
- if (isset($_GET['area']) && ($_GET['area'] !=='No preference')){
- $master.=' area.area_id=$area';
- }
- if (isset($_GET['rest']) && ($_GET['rest'] !=='No preference')){
- $master.=' rest.rest_id=$rest';
- }
- $result = $link->query($master);
- print "This is the master $master";
- if ($result->num_rows > 0) {
- 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>";
- // output data of each row
- while($row = $result->fetch_assoc()) {
- 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>";
- }
- echo "</table>";
- } else {
- echo "0 results";
- }
- $conn->close();
- mysqli_close($link);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment