<?php
header("Content-Type: application/json");
include "../config.php"; // adjust path as needed

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    // Simple query without filters
    $query = "SELECT `id`, `b_name` FROM `bank`";
    $result = mysqli_query($con, $query);

    if ($result) {
        $banks = [];
        while ($row = mysqli_fetch_assoc($result)) {
            $banks[] = $row;
        }
        echo json_encode(["success" => true, "data" => $banks]);
    } else {
        http_response_code(500);
        echo json_encode([
            "error" => "Database query failed.",
            "details" => mysqli_error($con)
        ]);
    }
} else {
    http_response_code(405);
    echo json_encode(["error" => "Only POST requests allowed."]);
}
?>