<?php
include 'config.php';
$conn->set_charset("utf8mb4");

// POST ইনপুট নিরাপদভাবে নেওয়া
$type = isset($_POST["type"]) ? $_POST["type"] : '';

if ($type === "AllRulse") {
    // Prepared Statement তৈরি
    $stmt = $conn->prepare("SELECT * FROM match_types");

    if ($stmt) {
        // Query রান
        $stmt->execute();

        // Result ফেচ করা
        $result = $stmt->get_result();
        $data = array();

        if ($result->num_rows > 0) {
            while ($row = $result->fetch_assoc()) {
                $data[] = $row;
            }
            echo json_encode($data, JSON_UNESCAPED_UNICODE);
        } else {
            echo "No Data Found";
        }

        $stmt->close();
    } else {
        echo "Query Prepare Failed!";
    }
}

$conn->close();
?>