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;
- background-color:#e6ffcc;
- padding: 10px;
- }
- </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'];
- $master = "SELECT master.master_id, rest.rest, marg.marg, area.area, flavor.flavor, type.type, happy_hour.hh FROM master INNER JOIN marg ON master.marg_id=marg.marg_id INNER JOIN rest ON master.rest_id=rest.rest_id INNER JOIN area ON master.area_id=area.area_id INNER JOIN flavor ON master.flavor_id=flavor.flavor_id INNER JOIN type on master.type_id=type.type_id INNER JOIN happy_hour on master.hh_id=happy_hour.hh_id";
- 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')) {
- $master.=" WHERE";
- }
- if (isset($_GET['type']) && $_GET['type'] !== 'No preference') {
- $master.=" type.type_id=$type";
- 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')) {
- $master.=" AND";
- }
- }
- if (isset($_GET['happy_hour']) && $_GET['happy_hour'] !=='No preference'){
- $master.=" happy_hour.hh_id=$hh";
- if ((isset($_GET['flavor']) && $_GET['flavor'] !== 'No preference') ||
- (isset($_GET['area']) && $_GET['area'] !== 'No preference') ||
- (isset($_GET['rest']) && $_GET['rest'] !== 'No preference')) {
- $master.=" AND";
- }
- }
- if (isset($_GET['flavor']) && $_GET['flavor'] !== 'No preference'){
- $master.=" flavor.flavor_id=$flavor";
- if ((isset($_GET['area']) && $_GET['area'] !== 'No preference') ||
- (isset($_GET['rest']) && $_GET['rest'] !== 'No preference')){
- $master.=" AND";
- }
- }
- if (isset($_GET['area']) && $_GET['area'] !=='No preference'){
- $master.=" area.area_id=$area";
- if (isset($_GET['rest']) && $_GET['rest'] !== 'No preference'){
- $master.=" AND";
- }
- }
- if (isset($_GET['rest']) && $_GET['rest'] !== 'No preference'){
- $master.=" rest.rest_id=$rest";
- }
- $master.=" ORDER BY rest.rest, marg.marg";
- $result = $link->query($master);
- if ($result->num_rows > 0) {
- echo "<table><tr><th>Restaurant</th><th>Margarita Name</th><th>Area of Austin</th><th>Flavor</th><th>Consistency</th><th>Happy Hour Availability</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. Stop being picky, all alcohol is good alcohol!";
- }
- $conn->close();
- mysqli_close($link);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment