Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <style>
  6. table, th, td
  7. {
  8. border: 1px solid black;
  9. align-content: center;
  10. background-color: lightblue;
  11. padding-top: 5px;
  12. padding-right: 30px;
  13. padding-bottom: 30px:
  14. padding-left: 50px;
  15. text-align: center;
  16. height: 50px;
  17. width: 500px;
  18.  
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <?php
  24. $servername = "localhost";
  25. $username = "root";
  26. $password = "";
  27. $dbname = "inventory";
  28.  
  29. // Create connection
  30. $conn = new mysqli($servername, $username, $password, $dbname);
  31. // Check connection
  32. if ($conn->connect_error) {
  33. die("Connection failed: " . $conn->connect_error);
  34. }
  35.  
  36. $sql = "SELECT bookid, title, author, accountnumber, callnumber FROM data";
  37. $result = $conn->query($sql);
  38.  
  39. if ($result->num_rows > 0) {
  40. echo "<table><tr><th>Book ID</th><th>Title</th><th>Author</th><th>Account Number</th><th>Call number</th></tr>";
  41. // output data of each row
  42. while($row = $result->fetch_assoc()) {
  43. echo "<tr><td>" . $row["bookid"]. "</td><td>" . $row["title"]. "</td><td>" . $row["author"]. "</td><td>" . $row["accountnumber"]. "</td><td>" . $row["callnumber"]. "</td></tr>";
  44. }
  45. echo "</table>";
  46. } else {
  47. echo "0 results";
  48. }
  49.  
  50. $conn->close();
  51. ?>
  52.  
  53. <a href="home.php">BACK</a></br>
  54. <a href="add.php">ADD</a>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement