Viewing file: viewbooks.php (1.76 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html> <html lang="en">
<?php include 'head.php';?> <style> table { border-collapse: collapse; width: 100%; margin-top: 20px; }
table, th, td { border: 1px solid #ddd; }
th, td { padding: 8px; text-align: left; }
th { background-color: #f2f2f2; font-weight: bold; } </style> <body>
<!-- ======= Header ======= --> <?php include 'menubar.php';?>
<?php include 'sidebar.php';?>
<main id="main" class="main">
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Book Library</title> </head> <body> <h1>Book Library</h1>
<?php include 'connect.php';
// Query the database to retrieve books $query = "SELECT * FROM books"; $result = $db->query($query);
if ($result->num_rows > 0) { echo "<table border='1'>"; echo "<tr><th>ID</th><th>Title</th><th>Author</th><th>Publication Year</th><th>ISBN</th><th>RATE</th><th>Update</th></tr>"; while ($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["id"] . "</td>"; echo "<td>" . $row["title"] . "</td>"; echo "<td>" . $row["author"] . "</td>"; echo "<td>" . $row["publication_year"] . "</td>"; echo "<td>" . $row["ISBN"] . "</td>"; echo "<td>" . $row["rate"] . "</td>"; echo '<td>' . "<a href='book_update_form.php?ID=".$row['ID']. "'>Update</a>". '</td>'; echo "</tr>"; } echo "</table>"; } else { echo "No books found in the database."; }
$db->close(); ?>
<a href="newbooks.php">Add a Book</a>
</body> </html>
</main><!-- End #main -->
<?php include 'footer.php';?>
</body>
</html>
|