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")}
- h1, p {text-align: center}
- table, th, td {
- border: 1px solid black;
- background-color:#e6ffcc;
- padding: 10px;
- }
- </style>
- <body>
- <h1>Poisons</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, 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";
- 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.=" AND";
- }
- 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 align=center><tr><th>Restaurant</th><th>Margarita Name</th><th>Area of Austin</th><th>Flavor</th><th>Consistency</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 "<h2>0 results. Stop being picky, all alcohol is good alcohol!</h2>";
- }
- $conn->close();
- mysqli_close($link);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment