<?php header("Access-Control-Allow-Origin: *");
  header("Access-Control-Allow-Headers: *");  

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

  include '../db/connectMe.php';   
  include '../function/function.php';  

  
  if (isset($_GET["c"]) ) {

    @$clubId = mysql_prep($_GET['c']);

    //positions
    $positions = find_all_positions(1);

    $i = 0;
    $players = []; 

    foreach ($positions as $position[] ) {

      //All club players
      $clubPlayers = find_all_club_players_for_position($clubId, $position[$i]->id, 1); 

      $position[$i]->players = $clubPlayers;
      $players = json_encode($position);

      $i++;

    }

    exit($players);

  }
