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;
- }
- .booktable {
- width=100%;
- }
- .bookheader {
- }
- </style>
- </head>
- <body>
- <div class="titlebar" id="titlebar" name="titlebar">
- Griff's BookShop
- </div>
- <div class="mainarea" id="booklist" name="booklist">
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "xxxxxxxx";
- $dbname = "griffbookshop";
- // GET variables
- $book=$_GET['book'];
- $author=$_GET['author'];
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $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></tr>";
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "
- <tr><td><a href=index.php?book=" . str_replace(' ','_',$row['Title']) . ">" . $row["Title"] . "</a></td>
- <td><a href=index.php?author=" . str_replace(' ','_',$row['Author']) . ">" . $row["Author"] . "</a></td></tr>";
- }
- } else {
- echo "0 results";
- }
- //$echo "</table>";
- $conn->close();
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement