*/ require_once 'resources/config.php'; require_once 'resources/database.php'; $db = new Database(); $sport = ""; if(isset($_GET["sport"])){ $sport = $_GET["sport"]; } $allteams = $db->getTeams(); $teams_poules1 = array(); $teams_poules2 = array(); $matchs_poules1 = array(); $matchs_poules2 = array(); $matchs_eight = array(); $matchs_quarters = array(); $matchs_semis = array(); $matchs_final = array(); $matchs_little_final = array(); if($sport == "badminton"){ $matchs_eight1 = array(); $matchs_eight2 = array(); $matchs_quarters1 = array(); $matchs_quarters2 = array(); $matchs_semis1 = array(); $matchs_semis2 = array(); $matchs_final1 = array(); $matchs_final2 = array(); $matchs_final3 = array(); foreach($db->getMatches() as $match){ if(strtolower($match["sport_name"]) == strtolower($sport)."1"){ switch($match["type"]){ case 0: break; case 1: array_push($matchs_final3, $match); break; case 2: array_push($matchs_final1, $match); break; case 3: array_push($matchs_semis1, $match); break; case 4: array_push($matchs_little_final, $match); break; case 5: array_push($matchs_quarters1, $match); break; case 6: array_push($matchs_eight1, $match); break; default: break; } } if(strtolower($match["sport_name"]) == strtolower($sport)."2"){ switch($match["type"]){ case 0: break; case 1: break; case 2: array_push($matchs_final2, $match); break; case 3: array_push($matchs_semis2, $match); break; case 4: break; case 5: array_push($matchs_quarters2, $match); break; case 6: array_push($matchs_eight2, $match); break; default: break; } } } array_push($matchs_eight, $matchs_eight1); array_push($matchs_eight, $matchs_eight2); array_push($matchs_quarters, $matchs_quarters1); array_push($matchs_quarters, $matchs_quarters2); array_push($matchs_semis, $matchs_semis1); array_push($matchs_semis, $matchs_semis2); array_push($matchs_final, $matchs_final1); array_push($matchs_final, $matchs_final2); array_push($matchs_final, $matchs_final3); } else{ foreach($db->getMatches() as $match){ if(strtolower($match["sport_name"]) == strtolower($sport)){ switch($match["type"]){ case 0: array_push($matchs_poules1, $match); break; case 1: array_push($matchs_final, $match); break; case 2: array_push($matchs_semis, $match); break; case 3: array_push($matchs_quarters, $match); break; case 4: array_push($matchs_little_final, $match); break; case 7: array_push($matchs_poules2, $match); break; default: break; } } } } foreach($allteams as $team){ $found1 = false; $found2 = false; foreach($matchs_poules1 as $match){ if(json_decode($match["teams_id"])[0] == $team["id"] || json_decode($match["teams_id"])[1] == $team["id"]){ $found1 = true; } } foreach($matchs_poules2 as $match){ if(json_decode($match["teams_id"])[0] == $team["id"] || json_decode($match["teams_id"])[1] == $team["id"]){ $found2 = true; } } if($found1){ array_push($teams_poules1, $team); } if($found2){ array_push($teams_poules2, $team); } } ?> <?php echo $sport; ?>

0 || sizeof($matchs_final) == 0 && sizeof($matchs_semis) == 0 && sizeof($matchs_little_final) == 0){ ?>

Quarts de finale

"; if(sizeof($matchs_quarters) >= $i + 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_quarters[$i]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_quarters[$i]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_quarters[$i]["scores"])[1]){ echo " winner"; } elseif(json_decode($matchs_quarters[$i]["scores"])[0] < json_decode($matchs_quarters[$i]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_quarters[$i]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_quarters[$i]["scores"])[0]){ echo " winner"; } elseif(json_decode($matchs_quarters[$i]["scores"])[1] < json_decode($matchs_quarters[$i]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_quarters[$i]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; } ?>
Brace Brace

Demi-finales

"; if(sizeof($matchs_semis) >= $i + 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_semis[$i]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_semis[$i]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_semis[$i]["scores"])[1]){ echo " winner"; } elseif(json_decode($matchs_semis[$i]["scores"])[0] < json_decode($matchs_semis[$i]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_semis[$i]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_semis[$i]["scores"])[0]){ echo " winner"; } elseif(json_decode($matchs_semis[$i]["scores"])[1] < json_decode($matchs_semis[$i]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_semis[$i]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; } ?>
Brace

Finale

"; if(sizeof($matchs_final) >= 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_final[0]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_final[0]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_final[0]["scores"])[1]){ echo " gold-medal winner"; } elseif(json_decode($matchs_final[0]["scores"])[0] < json_decode($matchs_final[0]["scores"])[1]){ echo " silver-medal loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_final[0]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_final[0]["scores"])[0]){ echo " gold-medal winner"; } elseif(json_decode($matchs_final[0]["scores"])[1] < json_decode($matchs_final[0]["scores"])[0]){ echo " silver-medal loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_final[0]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; ?>

Petite finale

"; if(sizeof($matchs_little_final) >= 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_little_final[0]["scores"])[1]){ echo " bronze-medal winner"; } elseif(json_decode($matchs_little_final[0]["scores"])[0] < json_decode($matchs_little_final[0]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_little_final[0]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_little_final[0]["scores"])[0]){ echo " bronze-medal winner"; } elseif(json_decode($matchs_little_final[0]["scores"])[1] < json_decode($matchs_little_final[0]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_little_final[0]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; ?>

16èmes de finale

"; if($i != 1 && $i != 6){ $del_elems++; echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } elseif(sizeof($matchs_eight[$k-1]) >= $i - $del_elems + 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_eight[$k-1][$i - $del_elems]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_eight[$k-1][$i - $del_elems]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1]){ echo " winner"; } elseif(json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0] < json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0]){ echo " winner"; } elseif(json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1] < json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; } ?>
Brace Brace Brace Brace

8èmes de finale

"; if($i != 1 && $i != 2){ // SOMETHING THAT WOULD BE USELESS IN THE FUTUR --------------------------------- $del_elems++; echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } elseif(sizeof($matchs_quarters[$k-1]) >= $i - $del_elems + 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_quarters[$k-1][$i - $del_elems]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_quarters[$k-1][$i - $del_elems]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[1]){ echo " winner"; } elseif(json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[0] < json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[0]){ echo " winner"; } elseif(json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[1] < json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_quarters[$k-1][$i - $del_elems]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; } ?>
Brace Brace

Quarts de finale

"; if(sizeof($matchs_semis[$k-1]) >= $i + 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_semis[$k-1][$i]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_semis[$k-1][$i]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_semis[$k-1][$i]["scores"])[1]){ echo " winner"; } elseif(json_decode($matchs_semis[$k-1][$i]["scores"])[0] < json_decode($matchs_semis[$k-1][$i]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_semis[$k-1][$i]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_semis[$k-1][$i]["scores"])[0]){ echo " winner"; } elseif(json_decode($matchs_semis[$k-1][$i]["scores"])[1] < json_decode($matchs_semis[$k-1][$i]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_semis[$k-1][$i]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; } ?>
Brace

Demi-finales

"; if(sizeof($matchs_final[$k-1]) >= 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_final[$k-1][0]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_final[$k-1][0]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_final[$k-1][0]["scores"])[1]){ echo " gold-medal winner"; } elseif(json_decode($matchs_final[$k-1][0]["scores"])[0] < json_decode($matchs_final[$k-1][0]["scores"])[1]){ echo " silver-medal loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_final[$k-1][0]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_final[$k-1][0]["scores"])[0]){ echo " gold-medal winner"; } elseif(json_decode($matchs_final[$k-1][0]["scores"])[1] < json_decode($matchs_final[$k-1][0]["scores"])[0]){ echo " silver-medal loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_final[$k-1][0]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; ?>

Finale

"; if(sizeof($matchs_final[2]) >= 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_final[2][0]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_final[2][0]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_final[2][0]["scores"])[1]){ echo " gold-medal winner"; } elseif(json_decode($matchs_final[2][0]["scores"])[0] < json_decode($matchs_final[2][0]["scores"])[1]){ echo " silver-medal loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_final[2][0]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_final[2][0]["scores"])[0]){ echo " gold-medal winner"; } elseif(json_decode($matchs_final[2][0]["scores"])[1] < json_decode($matchs_final[2][0]["scores"])[0]){ echo " silver-medal loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_final[2][0]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; ?>

Petite finale

"; if(sizeof($matchs_little_final) >= 1){ $team1; $team2; foreach($allteams as $team){ if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[0]){ $team1 = $team; } if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[1]){ $team2 = $team; } } echo "
json_decode($matchs_little_final[0]["scores"])[1]){ echo " bronze-medal winner"; } elseif(json_decode($matchs_little_final[0]["scores"])[0] < json_decode($matchs_little_final[0]["scores"])[1]){ echo " loser"; } echo "\">"; echo "

".$team1["name"]."

"; echo "

".json_decode($matchs_little_final[0]["scores"])[0]."

"; echo "
"; echo "
json_decode($matchs_little_final[0]["scores"])[0]){ echo " bronze-medal winner"; } elseif(json_decode($matchs_little_final[0]["scores"])[1] < json_decode($matchs_little_final[0]["scores"])[0]){ echo " loser"; } echo "\">"; echo "

".$team2["name"]."

"; echo "

".json_decode($matchs_little_final[0]["scores"])[1]."

"; echo "
"; } else{ echo "
"; echo "

-

"; echo "

-

"; echo "
"; echo "
"; echo "

-

"; echo "

-

"; echo "
"; } echo "
"; ?>
".$team["name"].""; } ?> "; echo ""; foreach($teams_poules1 as $team2){ echo ""; } echo ""; $i++; } ?>
Poule A
".$team["name"].""; if($team2 != $team){ $found = false; foreach($matchs_poules1 as $match){ if(json_decode($match["teams_id"])[1] == $team["id"] && json_decode($match["teams_id"])[0] == $team2["id"]){ echo json_decode($match["scores"])[1]." - ".json_decode($match["scores"])[0]; $found = true; } if(json_decode($match["teams_id"])[0] == $team["id"] && json_decode($match["teams_id"])[1] == $team2["id"]){ echo json_decode($match["scores"])[0]." - ".json_decode($match["scores"])[1]; $found = true; } } if(!$found){ echo "-"; } } else{ echo "X"; } echo "
".$team["name"].""; } ?> "; echo ""; foreach($teams_poules2 as $team2){ echo ""; } echo ""; $i++; } ?>
Poule B
".$team["name"].""; if($team2 != $team){ $found = false; foreach($matchs_poules2 as $match){ if(json_decode($match["teams_id"])[1] == $team["id"] && json_decode($match["teams_id"])[0] == $team2["id"]){ echo json_decode($match["scores"])[1]." - ".json_decode($match["scores"])[0]; $found = true; } if(json_decode($match["teams_id"])[0] == $team["id"] && json_decode($match["teams_id"])[1] == $team2["id"]){ echo json_decode($match["scores"])[0]." - ".json_decode($match["scores"])[1]; $found = true; } } if(!$found){ echo "-"; } } else{ echo "X"; } echo "