<?php
include 'config.php';
header('Content-Type: application/json');

$data = [];

$result = mysqli_query($conn, "SELECT id, match_type, rules FROM match_rules ORDER BY id DESC");

while ($row = mysqli_fetch_assoc($result)) {
    $data[] = [
        "id" => $row['id'],
        "match_type" => $row['match_type'],
        "rules" => $row['rules']
    ];
}

echo json_encode([
    "status" => true,
    "count" => count($data),
    "data" => $data
], JSON_UNESCAPED_UNICODE);
?>