<?php
include "../db.php";

if (isset($_POST['course_id'])) {
    $course_id = mysqli_real_escape_string($con, $_POST['course_id']);

    $query = "SELECT * FROM branch WHERE b_class = '$course_id' AND b_recycle = '1' ORDER BY batch_title ASC";
    $result = mysqli_query($con, $query);

    echo '<option value="">Select Batch</option>';

    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            echo '<option value="' . htmlspecialchars($row['b_id']) . '">' . htmlspecialchars($row['batch_title']) . '</option>';
        }
    } else {
        echo '<option value="">No Batch Available</option>';
    }
}
?>