-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-leagues.php
73 lines (63 loc) · 2.13 KB
/
my-leagues.php
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
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Leagues</title>
<link rel="stylesheet" href="grid.css" />
</head>
<body>
<?php
include('header.php');
include('db-helpers.php');
if (isset($_SESSION['user'])) {
$my_admin_id = getMyAdminId($_SESSION['user']);
if (!empty($my_admin_id)) $leagues = getMyLeagues($my_admin_id);
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['league_id'])) {
$_SESSION['league_id'] = $_POST['league_id'];
$_SESSION['league_name'] = $_POST['league_name'];
if ($_POST['action'] == 'Manage') {
header('Location: addteams.php');
} else if ($_POST['action'] == 'Schedule') {
header('Location: schedule.php');
}
}
}
?>
<div class="grid-container">
<div class="grid-header">
<h1>My Leagues</h1>
</div>
<?php foreach ($leagues as $league): ?>
<div class="grid-row">
</br>
<h3><?php echo $league['league_name'] ?></h3>
</br>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<input type="submit" name="action" value="Manage" class="btn-grid" />
<input type="submit" name="action" value="Schedule" class="btn-grid" />
<input type="hidden" name="league_id" value="<?php echo $league['league_id'] ?>" />
<input type="hidden" name="league_name" value="<?php echo $league['league_name'] ?>" />
</form>
</br>
</div>
<?php endforeach; ?>
<div class ="grid-row">
<form action="createleague.php">
<br/>
<input type="submit" class="btn-grid" value="Create a New League" />
<br/>
</form>
</div>
</div>
</body>
<?php
function getMyLeagues($admin_id) {
global $db;
$query = "SELECT * FROM league WHERE admin_id = '" . $admin_id . "'";
$sql = $db->prepare($query);
$sql->execute();
$result = $sql->fetchAll();
$sql->closeCursor();
return $result;
}
?>
</html>