Advertisement
Guest User

Untitled

a guest
Jan 26th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <html>
  2.   <head>
  3.     <title="Griff's Book Shop">
  4.   <head>
  5.         <style>
  6.           .titlebar {
  7.             width:1000px;
  8.             height:150px;
  9.             margin:auto;
  10.             border: 1px solid #000000;
  11.             font-size: 62;
  12.             text-align: center;
  13.           }
  14.           .mainarea {
  15.             width:1000px;
  16.             height:600px;
  17.             margin:auto;
  18.             border: 1px solid #000000;
  19.             overflow:scroll;
  20.           }
  21.           .booktable {
  22.             width=100%;
  23.           }
  24.           .bookheader {
  25.           }
  26.         </style>
  27.  
  28.   </head>
  29.   <body>
  30.         <div class="titlebar" id="titlebar" name="titlebar">
  31.                 Griff's BookShop
  32.         </div>
  33.  
  34.         <div class="mainarea" id="booklist" name="booklist">
  35.  
  36. <?php
  37. $servername = "localhost";
  38. $username = "root";
  39. $password = "xxxxxxxx";
  40. $dbname = "griffbookshop";
  41.  
  42. // GET variables
  43.  
  44. $book=$_GET['book'];
  45. $author=$_GET['author'];
  46.  
  47. // Create connection
  48. $conn = new mysqli($servername, $username, $password, $dbname);
  49. // Check connection
  50. if ($conn->connect_error) {
  51.     die("Connection failed: " . $conn->connect_error);
  52. }
  53.  
  54. $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";
  55. $result = $conn->query($sql);
  56.  
  57.  
  58. echo "<table class='booktable' id='booktable'><tr class='bookheader' id='bookheader'><td><b>Title</b></td><td><b>Author</b></td></tr>";
  59.  
  60. if ($result->num_rows > 0) {
  61. //     output data of each row
  62.        while($row = $result->fetch_assoc()) {
  63.         echo "
  64.  
  65. <tr><td><a href=index.php?book=" . str_replace(' ','_',$row['Title']) . ">" . $row["Title"] . "</a></td>
  66. <td><a href=index.php?author=" . str_replace(' ','_',$row['Author']) . ">" . $row["Author"] . "</a></td></tr>";
  67.  
  68.     }
  69. } else {
  70.     echo "0 results";
  71. }
  72.  
  73. //$echo "</table>";
  74.  
  75. $conn->close();
  76. ?>
  77.  
  78.         </div>
  79.   </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement