-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteam.php
More file actions
66 lines (54 loc) · 2.04 KB
/
team.php
File metadata and controls
66 lines (54 loc) · 2.04 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
60
61
62
63
64
65
66
<?php
// Load the teams data
require 'data.php';
// Get the team name from the URL (example: team.php?team=Barcelona)
// If there is no "team" in the URL, we set $teamName to null
// Without this line, PHP would throw a notice/warning.
if (isset($_GET['team'])) {
$teamName = $_GET['team'];
} else {
$teamName = null;
}
// Check if the team exists in our data array
if ($teamName && isset($teams[$teamName])) {
$team = $teams[$teamName]; // Team found, store its data in $team
} else {
$team = null; // Team not found or no team provided
}
?>
<?php
// Include the common header (navigation, opening HTML tags)
require 'header.php';
?>
<main class="team-detail">
<!-- If $team is valid → show the team details. If $team is null → show the “Team not found” message. -->
<?php if ($team): ?>
<!-- Display team information -->
<h1><?php echo $teamName; ?></h1>
<img src="<?php echo $team['logo']; ?>"
alt="<?php echo $teamName; ?> logo"
class="team-logo-large"> <!-- team logo to appear larger than the small logos on the homepage. -->
<p><strong>League:</strong> <?php echo $team['league']; ?></p>
<p><strong>City:</strong> <?php echo $team['city']; ?></p>
<p><strong>UEFA Ranking:</strong> <?php echo $team['uefa-coefficient-ranking']; ?></p>
<h2>Opponents</h2>
<ul>
<?php
// Loop through the opponents array and display each one
foreach ($team['opponents'] as $opponent):
?>
<li><?php echo $opponent; ?></li>
<?php endforeach; ?>
</ul>
<!-- Create clickable link to the team’s official site. -->
<p><a href="<?php echo $team['url']; ?>" target="_blank">Visit Official Website</a></p>
<?php else: ?>
<!-- Show message if team not found -->
<h1>Team not found</h1>
<p>The team you are looking for does not exist.</p>
<?php endif; ?>
</main>
<?php
// 7. Include the common footer (closes HTML tags)
require 'footer.php';
?>