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

$query_terms = "SELECT * FROM terms";
$result_terms = $conn->query($query_terms);

$query_sessions = "SELECT * FROM sessions";
$result_sessions = $conn->query($query_sessions);
?>

<!DOCTYPE html>
<html>
<head>
    <title>Term Profit and Loss</title>
    <link rel="stylesheet" type="text/css" href="#">
     <style type="text/css">
        .container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f4f4f4;
    border-radius: 8px;
}

h2 {
    text-align: center;
    margin-bottom: 20px;
}

form {
    display: flex;
    flex-direction: column;
    align-items: center;
}

label {
    margin-top: 10px;
}

select, button {
    margin-top: 5px;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

button {
    background-color: #007bff;
    color: white;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

    </style>
</head>
<body>
    <div class="container">
        <h2>Termly Profit and Loss Statement</h2>
        <form action="view_term_profit_loss.php" method="POST">
            <label for="term">Select Term:</label>
            <select id="term" name="term">
                <?php while ($row = $result_terms->fetch_assoc()) { ?>
                    <option value="<?php echo $row['term_name']; ?>"><?php echo $row['term_name']; ?></option>
                <?php } ?>
            </select>

            <label for="session">Select Session:</label>
            <select id="session" name="session">
                <?php while ($row = $result_sessions->fetch_assoc()) { ?>
                    <option value="<?php echo $row['session_name']; ?>"><?php echo $row['session_name']; ?></option>
                <?php } ?>
            </select>
            <button type="submit">View Profit and Loss</button>
        </form>
    </div>
</body>
</html>
