Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title="Griff's Book Shop">
- <head>
- <style>
- .titlebar {
- width:1000px;
- height:150px;
- margin:auto;
- border: 1px solid #000000;
- font-size: 62;
- text-align: center;
- }
- .mainarea {
- width:1000px;
- height:600px;
- margin:auto;
- border: 1px solid #000000;
- overflow:scroll;
- }
- .titledetails {
- width:1000px;
- height:600px;
- margin:auto;
- border: 1px solid #000000;
- overflow:scroll;
- display: none;
- }
- .booktable {
- width=100%;
- }
- .backbutton {
- font-size: small;
- }
- </style>
- <?php
- $servername = "localhost";
- $username = "xxxxxxxxx";
- $password = "xxxxxxxxx";
- $dbname = "griffbookshop";
- // GET variables
- $title=$_GET['book'];
- $author=$_GET['author'];
- $publisher=$_GET['publisher'];
- $genre=$_GET['genre'];
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- ?>
- </head>
- <body>
- <div class="titlebar" id="titlebar" name="titlebar">
- Griff's BookShop <br />
- <a href="index.php"><span class="backbutton">Back to Index</span></a>
- </div>
- <div class="mainarea" id="booklist" name="booklist">
- <?php
- $sql = "SELECT * FROM books";
- $result = $conn->query($sql);
- echo "<form><table><tr><td><select id=dropdowntitles onchange=''>";
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<option value='". $row[Title] . "'>". $row[Title] . "</option>";
- }
- } else {
- echo "<option value='0 results'></option>";
- }
- echo "</select></td>";
- echo "<td><select id=dropdownauthors onchange=''>";
- $sql = "SELECT * FROM authors";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<option value='". $row[Author] . "'>". $row[Author] . "</option>";
- }
- } else {
- echo "<option value='0 results'></option>";
- }
- echo "</select></td>";
- echo "<td><select id=dropdownpublisher onchange=''>";
- $sql = "SELECT * FROM publisher";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<option value='". $row[Publisher] . "'>". $row[Publisher] . "</option>";
- }
- } else {
- echo "<option value='0 results'></option>";
- }
- echo "</select></td>";
- echo "<td><select id=dropdowngenre onchange=''>";
- $sql = "SELECT * FROM genre";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<option value='". $row[Genre] . "'>". $row[Genre] . "</option>";
- }
- } else {
- echo "<option value='0 results'></option>";
- }
- echo "</select></td></tr></table></form>";
- if ($book != '') {
- echo "Book Selected - " . $title;
- $sql = "SELECT b.BookID,b.Title,a.Author,g.Genre,f.Fictional,p.Publisher FROM books b JOIN authors a ON a.AuthorId=b.BookId JOIN genre g ON g.GenreId=b.GenreID JOIN fictional f ON f.FictionalID=b.FictionalID JOIN publisher p on p.PublisherID=b.PublisherID WHERE b.Title='" . str_replace('_',' ',$title) . "'";
- } elseif ($author != '') {
- echo "Author Selected - " . $author;
- $sql = "SELECT b.BookID,b.Title,a.Author,g.Genre,f.Fictional,p.Publisher FROM books b JOIN authors a ON a.AuthorId=b.BookId JOIN genre g ON g.GenreId=b.GenreID JOIN fictional f ON f.FictionalID=b.FictionalID JOIN publisher p on p.PublisherID=b.PublisherID WHERE a.Author='" . str_replace('_',' ',$author) . "'";
- } elseif ($publisher != '') {
- echo "Publisher Selected - " . $publisher;
- $sql = "SELECT b.BookID,b.Title,a.Author,g.Genre,f.Fictional,p.Publisher FROM books b JOIN authors a ON a.AuthorId=b.BookId JOIN genre g ON g.GenreId=b.GenreID JOIN fictional f ON f.FictionalID=b.FictionalID JOIN publisher p on p.PublisherID=b.PublisherID WHERE p.Publisher='" . str_replace('_',' ',$publisher) . "'";
- } elseif ($genre != '') {
- echo "Genre Selected - " . $genre;
- $sql = "SELECT b.BookID,b.Title,a.Author,g.Genre,f.Fictional,p.Publisher FROM books b JOIN authors a ON a.AuthorId=b.BookId JOIN genre g ON g.GenreId=b.GenreID JOIN fictional f ON f.FictionalID=b.FictionalID JOIN publisher p on p.PublisherID=b.PublisherID WHERE g.genre='" . str_replace('_',' ',$genre) . "'";
- } else {
- echo "Nothing selected!";
- $sql = "SELECT b.BookID,b.Title,a.Author,g.Genre,f.Fictional,p.Publisher FROM books b JOIN authors a ON a.AuthorId=b.BookId JOIN genre g ON g.GenreId=b.GenreID JOIN fictional f ON f.FictionalID=b.FictionalID JOIN publisher p on p.PublisherID=b.PublisherID";
- }
- $result = $conn->query($sql);
- echo "<table class='booktable' id='booktable'><tr class='bookheader' id='bookheader'><td><b>Title</b></td><td><b>Author</b></td><td><b>Publisher</b></td><td><b>Genre</b></td></tr>";
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "
- <tr>
- <td>" . $row["Title"] . "</td>
- <td><a href=index.php?author=" . str_replace(' ','_',$row['Author']) . ">" . $row["Author"] . "</a></td>
- <td><a href=index.php?publisher=" . str_replace(' ','_',$row['Publisher']) . ">" . $row["Publisher"] . "</a></td>
- <td><a href=index.php?genre=" . str_replace(' ','_',$row['Genre']) . ">" . $row["Genre"] . "</a></td>
- </tr>
- ";
- }
- } else {
- echo "0 results";
- }
- //$echo "</table>";
- $conn->close();
- ?>
- </div>
- <div class="titledetails" id="titledetails">
- sdfsfdsfd
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement