-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsonResult.php
More file actions
59 lines (46 loc) · 2.5 KB
/
jsonResult.php
File metadata and controls
59 lines (46 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
include_once 'database.php';
include_once 'teams.php';
include_once 'matches.php';
include_once 'results.php';
$database = new Database();
$db = $database->connect();
$teams = new Teams($db);
$teamsAll = $teams->getTeams();
$num = $teamsAll->rowCount();
$results = new Results($db);
if($num > 0){
$json_array = array();
while($row = $teamsAll->fetch(PDO::FETCH_ASSOC)){
$goalsFor = $results->goalsFor($row['country']); //vraca broj datih golova
$goalsAgainst = $results->goalsAgainst($row['country']); //vraca broj primljenih golova
$goal_differential = $results->goal_differential($row['country']); //vraaca gol razliku
$getWins = $results->getWins($row['country']); //vraca broj pobeda
$getDraws = $results->getDraws($row['country']); //vraca broj neresenih
$gamesPlayed = $results->gamesPlayed($row['country']); //vraca broj odigranih utakmica
$getLosses = $results->getLosses($row['country']); //vraca broj izgubljenih utakmica
$getPoints = $results->getPoints($row['country']); //vraca poene ukupno
$getPointsGroup = $results->getPointsGroup($row['country']); //vraca broj bodova u grupi ali nisam ubacivao dole jer je u zadataku ukupan broj bodova
$json_array = array(
'id' => $row['id'],
'country' => $row['country'],
'alternate_name' => $row['alternate_name'],
'fifa_code' => $row['fifa_code'],
'group_id' => $row['group_id'],
'group_letter' => $row['group_letter'],
'wins' => $getWins,
'draws' => $getDraws,
'losses' => $getLosses,
'games_played' => $gamesPlayed,
'points' => $getPoints,
'goals_for' => $goalsFor,
'goals_against' => $goalsAgainst,
'goal_differential' => $goal_differential,
);
$json_arr[]=$json_array;
}
}
echo "<br>";
print_r(json_encode($json_arr));
echo "<br>";
?>