<?php

header("Content-Type: application/json");

header("Access-Control-Allow-Origin: *");

require_once "../config/database.php";

$sql = "SELECT * FROM matches";

$result = $conn->query($sql);

$matches = [];

while($row = $result->fetch_assoc()){

  $matches[] = [

    "title" =>
      $row["clan"] .
      " vs " .
      $row["enemy_clan"],

    "start" =>
      $row["match_date"] .
      "T" .
      $row["match_time"],

    "extendedProps" => [

      "format" => $row["format_type"],

      "mapName" => $row["map_name"],

      "point" => $row["dispute_point"],

      "rules" => $row["rules"],

      "comments" => $row["comments"]
    ]
  ];
}

echo json_encode($matches);