<?php
require 'config.php';

$division_id = (int)($_GET['division_id'] ?? 0);

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

if ($division_id > 0) {
    $stmt = $conn->prepare("
        SELECT id, designation_name
        FROM designations
        WHERE division_id = ? AND status = 1
        ORDER BY designation_name
    ");
    $stmt->bind_param("i", $division_id);
    $stmt->execute();
    $res = $stmt->get_result();

    while ($row = $res->fetch_assoc()) {
        echo "<option value='{$row['id']}'>
                ".htmlspecialchars($row['designation_name'])."
              </option>";
    }
    $stmt->close();
}
