<!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 Sale Details</h1>

    <?php
    // Connect to the database (replace with your database credentials)
    $db = new mysqli('localhost', 'tslibrary_user', 'rb!tsl838', 'tslibrary_data');

    // Check for errors in the database connection
    if ($db->connect_error) {
        die("Connection failed: " . $db->connect_error);
    }

    // Query the database to retrieve books
    $query = "SELECT * FROM book_sale";
    $result = $db->query($query);

    if ($result->num_rows > 0) {
        echo "<table border='1'>";
        echo "<tr><th>ID</th><th>Student ID</th><th>Issue Date</th><th>Book </th><th>Rate</th><th>Dsicount</th><th>Payment</th></tr>";
        while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row["id"] . "</td>";
            echo "<td>" . $row["student_id"] . "</td>";
            echo "<td>" . $row["issuedate"] . "</td>";
            echo "<td>" . $row["book_id"] . "</td>";
            echo "<td>" . $row["rate"] . "</td>";
			echo "<td>" . $row["discount"] . "</td>";
			echo "<td>" . $row["payment_amount"] . "</td>";
			
			
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "No books found in the database.";
    }

    $db->close();
    ?>

    

</body>
</html>





  </main><!-- End #main -->

   <?php include 'footer.php';?>

</body>

</html>


