koerseadmin/server/getteams.php

34 lines
748 B
PHP

<?php
include_once("db.php");
//make result object
$result = array();
$result['ok'] = false;
//get post data
$postdata = file_get_contents("php://input");
$post = json_decode($postdata, true);
$idchampionship = $post['idchampionship'];
//fetch the championships
$teamfetch = pg_prepare($dbconn, "teamfetch", "select team.* from team inner join team_championship using (idteam) where idchampionship = $1");
$teamfetch = pg_execute($dbconn, "teamfetch", array($idchampionship));
//build result object
$teams = array();
while($row = pg_fetch_assoc($teamfetch)) {
$teams[] = $row;
}
$result['teams'] = $teams;
//return data
$result['ok'] = true;
//print message
$resultjson = json_encode($result);
echo $resultjson;
?>