<!DOCTYPE html>
<html lang="en">

<head>
    <title>Assign Subjects</title>
    <!-- Include your CSS and other necessary files here -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
       <link rel="stylesheet" href="styles.css">
           <!-- DataTables CSS -->
    <link rel="stylesheet" href="css/jquery.dataTables.min.css">


    <!-- DataTables JavaScript -->
    <script src="js/jquery.dataTables.min.js"></script>
</head>
<body>
<?php
// get_remaining_subjects.php

// Include your database connection file
include("includes/db.php");

if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["class_id"])) {
    $classId = $conn->real_escape_string($_POST["class_id"]);

    // Fetch remaining subjects not assigned to the selected class
    $query = "SELECT id, subject_name , subject_code FROM subjects WHERE id NOT IN 
              (SELECT subject_id FROM class_subject_mapping WHERE class_id = '$classId')";
    $result = $conn->query($query);

    if ($result->num_rows > 0) {
        echo '<div class="container">';
        echo '<h2>Remaining Subjects</h2>';
            
            

        while ($row = $result->fetch_assoc()) {
            echo '<input class="" style="width:16px; height:16px" type="checkbox" name="remaining_subjects[]" value="'  .$row['id'] .      '">'.'<span style="font-size:16px; margin-left:10px">'. $row['subject_name'].'</span> '.'(<span style="font-size:16px; margin-left:10px">'. $row['subject_code'].'</span>)<br>';

        }

        echo '</div>';
    } else {
        echo '<p>All subjects are already assigned to this class.</p>';
    }

    // Close the database connection
    $conn->close();
}
?>
<script type="text/javascript">

</script>
</body>
</html>