Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Results</title>
- </head>
- <body>
- <!-- make it look pretty --!>
- <style type="text/css">
- body {background-image: url("http://www.glorioustreats.com/wp-content/uploads/2011/06/Margarita-Cookies.jpg")}
- h1 {
- font-family: arial, sans-serif;
- text-align: center;
- }
- h2 {
- font-family: arial, sans-serif;
- text-align: center;
- padding: 10 0 0 20;
- font-size: 20px;
- }
- h3 {
- font-family: arial, sans-serif;
- text-align: left;
- padding: 10 0 0 20;
- font-size: 18px;
- }
- h4 {
- font-family: arial, sans-serif;
- text-align: left;
- padding: 10 0 0 20;
- font-size: 18px;
- color: #228B22;
- }
- p {
- font-family: arial, sans-serif;
- padding: 10 0 0 20;
- }
- table {
- max-width: 1000px;
- padding: 10px 20px;
- background: #f4f7f8;
- margin: 10px auto;
- padding: 20px;
- background: #f4f7f8;
- border-radius: 8px;
- font-family: arial, sans-serif;
- }
- table.primary tr:nth-child(odd) {
- background-color: #c9e7a3;
- }
- table.primary tr:nth-child(even) {
- background-color: #f4f7f8;
- }
- table.primary tr.new {
- background-color: #f4f7f8;
- }
- .inlineTable {
- float:left;
- }
- td, th {
- text-align: center;
- padding: 8px;
- }
- .form-style-5{
- max-width: 500px;
- padding: 10px 20px;
- background: #f4f7f8;
- margin: 10px auto;
- padding: 20px;
- background: #f4f7f8;
- border-radius: 8px;
- font-family: arial, sans-serif;
- }
- .form-style-5 fieldset{
- border: none;
- }
- .form-style-5 legend {
- font-size: 1.4em;
- margin-bottom: 10px;
- }
- .form-style-5 label {
- display: block;
- margin-bottom: 8px;
- }
- .form-style-5 select {
- font-family: arial, sans-serif;
- background: rgba(255,255,255,.1);
- border: none;
- border-radius: 4px;
- font-size: 16px;
- margin: 0;
- outline: 0;
- padding: 7px;
- width: 100%;
- box-sizing: border-box;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- background-color: #e8eeef;
- color:#8a97a0;
- -webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
- box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
- margin-bottom: 30px;
- }
- .form-style-5 select:focus{
- background: #d2d9dd;
- }
- .form-style-5 select{
- -webkit-appearance: menulist-button;
- height:35px;
- }
- .form-style-5 .number {
- background: #1abc9c;
- color: #fff;
- height: 30px;
- width: 30px;
- display: inline-block;
- font-size: 0.8em;
- margin-right: 4px;
- line-height: 30px;
- text-align: center;
- text-shadow: 0 1px 0 rgba(255,255,255,0.2);
- border-radius: 15px 15px 15px 0px;
- }
- .form-style-5 input[type="submit"],
- .form-style-5 input[type="button"]
- {
- position: relative;
- display: block;
- padding: 19px 39px 18px 39px;
- color: #FFF;
- margin: 0 auto;
- background: #1abc9c;
- font-size: 18px;
- text-align: center;
- font-style: normal;
- width: 100%;
- border: 1px solid #16a085;
- border-width: 1px 1px 3px;
- margin-bottom: 10px;
- }
- .form-style-5 input[type="submit"]:hover,
- .form-style-5 input[type="button"]:hover
- {
- background: #109177;
- }
- </style>
- <body>
- <?php
- // set up connection to the database
- $host="localhost";
- $username="alcohaul";
- $password="drunk";
- $database="alcohaul";
- // set up variable to connect to the database
- $link= mysqli_connect($host,$username,$password,$database);
- // get data from the form and sanitize inputs
- $type = preg_replace("/[^ 0-9a-zA-Z]+/", "", $_GET['type']);
- $hh = preg_replace("/[^ 0-9a-zA-Z]+/", "", $_GET['happy_hour']);
- $flavor = preg_replace("/[^ 0-9a-zA-Z]+/", "", $_GET['flavor']);
- $area = preg_replace("/[^ 0-9a-zA-Z]+/", "", $_GET['area']);
- $rest = preg_replace("/[^ 0-9a-zA-Z]+/", "", $_GET['rest']);
- // master select statement that includes joins
- $master = "SELECT master.master_id, rest.rest, marg.marg, area.area, flavor.flavor, type.type, happy_hour.hh FROM master LEFT JOIN marg ON master.marg_id=marg.marg_id LEFT JOIN rest ON master.rest_id=rest.rest_id LEFT JOIN area ON master.area_id=area.area_id LEFT JOIN flavor ON master.flavor_id=flavor.flavor_id LEFT JOIN type on master.type_id=type.type_id LEFT JOIN happy_hour on master.hh_id=happy_hour.hh_id";
- $master.=" ORDER BY rest.rest, marg.marg";
- $result = $link->query($master);
- // if results >0... print table of results
- if ($result->num_rows > 0) {
- echo "<table class='primary'><tr class='new';><th colspan='6'><h1>All Poisons</h1></th></tr><tr class='new';><th colspan='6'><form method=GET action='marg.php' class='form-style-5'></select><input type='submit' value='Back to Search'></h3></form></th></tr><tr class='new';><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 {
- // if no results are yeilded from search query, error message
- echo "0 results. Stop being picky, all alcohol is good alcohol!";
- }
- $conn->close();
- $conn->close();
- // close link to mysql database
- mysqli_close($link);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement