<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Add Enrollment</title>
    <link rel="stylesheet" href="#"> <!-- Add your CSS file -->
    <style type="text/css">
        /* form_styles.css */
        form {
            max-width: 600px;
            margin: 50px auto;
            padding: 20px;
            background: #f4f7f8;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        form h2 {
            margin-bottom: 20px;
            font-size: 24px;
            font-weight: 600;
            color: #333;
        }

        label {
            display: block;
            margin-bottom: 10px;
            font-weight: 500;
            color: #666;
        }

        input[type="text"],
        select {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        button[type="submit"] {
            width: 100%;
            padding: 10px;
            background: #007bff;
            border: none;
            border-radius: 4px;
            color: #fff;
            font-size: 16px;
            cursor: pointer;
        }

        button[type="submit"]:hover {
            background: #0056b3;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .error {
            color: red;
            margin-bottom: 20px;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <?php include 'header.php'; ?>
    <h2>Add Enrollment</h2>
    <form method="post" action="process_enrollment.php">
        <label for="student_id">Student:</label>
        <select id="student_id" name="student_id" required>
            <?php
            include('db_connection.php');
            $query_students = "SELECT student_id, name FROM students";
            $result_students = $conn->query($query_students);

            if ($result_students->num_rows > 0) {
                while ($row_student = $result_students->fetch_assoc()) {
                    echo "<option value='" . $row_student['student_id'] . "'>" . $row_student['name'] . "</option>";
                }
            } else {
                echo "<option value=''>No students found</option>";
            }
            ?>
        </select>

        <label for="subject_id">Subject:</label>
        <select id="subject_id" name="subject_id" required>
            <?php
            $query_subjects = "SELECT subject_id, subject_name FROM subjects";
            $result_subjects = $conn->query($query_subjects);

            if ($result_subjects->num_rows > 0) {
                while ($row_subject = $result_subjects->fetch_assoc()) {
                    echo "<option value='" . $row_subject['subject_id'] . "'>" . $row_subject['subject_name'] . "</option>";
                }
            } else {
                echo "<option value=''>No subjects found</option>";
            }
            ?>
        </select>

        <button type="submit">Add Enrollment</button>
    </form>
</body>
</html>
