<?php
// Include the database connection
include 'db_connection.php';
?>

<!DOCTYPE html>
<html>
<head>
    <title>View Transactions</title>
    <link rel="stylesheet" type="text/css" href="#">
    <style type="text/css">
    body {
    font-family: Arial, sans-serif;
}

h2 {
    text-align: center;
}

form {
    width: 300px;
    margin: 0 auto;
}

label {
    display: block;
    margin: 10px 0 5px;
}

input[type="text"], input[type="number"], input[type="date"], input[type="file"] {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
}

input[type="submit"] {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
}

table {
    width: 80%;
    margin: 20px auto;
    border-collapse: collapse;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #4CAF50;
    color: white;
}

    </style>
</head>
<body>
    <h2>View Transactions</h2>
    <h3>Income</h3>
    <table>
        <tr>
            <th>Income ID</th>
            <th>Source</th>
            <th>Amount</th>
            <th>Date</th>
        </tr>
        <?php
        $query = "SELECT * FROM income";
        $result = $conn->query($query);
        while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row['income_id'] . "</td>";
            echo "<td>" . $row['source'] . "</td>";
            echo "<td>" . $row['amount'] . "</td>";
            echo "<td>" . $row['date'] . "</td>";
            echo "</tr>";
        }
        ?>
    </table>

    <h3>Expenses</h3>
    <table>
        <tr>
            <th>Expense ID</th>
            <th>Description</th>
            <th>Amount</th>
            <th>Date</th>
        </tr>
        <?php
        $query = "SELECT * FROM expenses";
        $result = $conn->query($query);
        while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row['expense_id'] . "</td>";
            echo "<td>" . $row['description'] . "</td>";
            echo "<td>" . $row['amount'] . "</td>";
            echo "<td>" . $row['date'] . "</td>";
            echo "</tr>";
        }
        ?>
    </table>
</body>
</html>
