-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamsanwesenheit.php
56 lines (55 loc) · 1.51 KB
/
teamsanwesenheit.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
<?php
require(__DIR__."/lib/db_connection.php");
$db_connection = new DB_Connection();
$pdo = $db_connection -> getPDO();
/*
$found = false;
for($i=0;$i<20;$i++) if(isset($_POST["nicht anwesend"])) {
$found = true;
break;
}*/
if(isset($_POST["anwesend"])) {
$db_teams = $pdo -> prepare('UPDATE team SET anwesenheit=1 WHERE teamID=:teamID');
$db_teams -> execute(array(":teamID"=>$_POST["anwesend"]));
}
else if(isset($_POST["nichtanwesend"])) {
$db_teams = $pdo -> prepare('UPDATE team SET anwesenheit=0 WHERE teamID=:teamID');
$db_teams -> execute(array(":teamID"=>$_POST["nichtanwesend"]));
}
?>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="lib/stylesheet.css">
<style>
tbody tr td:first-child {
text-align:right;
}
</style>
</head>
<body>
<h1>Teamliste</h1>
<form method="post">
<table class="list">
<thead>
<tr>
<th></th>
<th>Teamname</th>
</tr>
</thead>
<tbody>
<?php
$db_teams = $pdo -> prepare('SELECT * FROM team');
$db_teams -> execute();
while ($team=$db_teams->fetch(PDO::FETCH_ASSOC)) {
echo "<tr><td>";
if(!$team["anwesenheit"]) echo "<button name='anwesend' value='".$team["teamID"]."'><b>nicht anwesend</b></button>";
else echo "<button name='nichtanwesend' value='".$team["teamID"]."'>anwesend</button>";
echo "</td><td>".$team["teamname"]."</td></tr>";
}
?>
</tbody>
</table>
</form>
</body>
</html>