Show sourcecode
The following files exists in this folder. Click to view.
access-deneid.png
diagramresultat.php
insert-admin.php
login.php
logout.php
personliga-resultat.php
quiz-sida.php
ransa-quiz-session.php
ransa-skapa-quiz-session.php
resultat.php
session-variabler-unset.php
signin.php
skapa-inloggning-tabell.php
skapa-quiz-tabeller.php
skapa-quiz.php
start.php
tabort-kunder-quiz.php
åtkomst-nekad.php
resultat.php
109 lines UTF-8 Windows (CRLF)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
th{
background-color:darkblue;
color: white;
}
h2{
margin:0;
}
table{
border-collapse:collapse;
margin:0;
font-size:16px;
text-align: left;
}
table,th,td{
border:1px solid black;
}
th,td {
padding: 10px;
}
tr:hover{
background-color:#f1f1f1;
}
div{
margin-left:30px;
width:400px;
display:flex;
flex-direction:column;
}
</style>
</head>
<body>
<?php
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current(): string {
return "<td>" . parent::current(). "</td>";
}
function beginChildren(): void {
echo "<tr>";
}
function endChildren(): void {
echo "</tr>" . "\n";
}
}
include ('../../dbconnection.php');
?>
<br>
<a href="start.php">Tillbaka till start</a>
<?php
$quizerIdLista = array();
$quizerNamnLista = array();
$sql = "SELECT * FROM quizer";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
array_push($quizerIdLista, $res['id']);
array_push($quizerNamnLista, $res['namn']);
}
?>
<div>
<?php
for ($i=0; $i < count($quizerIdLista); $i++){
echo "<table>";
echo "<br> <br>";
echo "<h2>"."Quiz ".$quizerNamnLista[$i]. "</h2>";
echo "<tr><th>Användarnamn</th><th>Antal Rätt</th></tr>";
$stmt = $dbconn->prepare(
"SELECT kunder.username, resultat.antalrätt
FROM resultat
JOIN kunder ON resultat.kundid = kunder.id
WHERE quizid = $quizerIdLista[$i]
ORDER BY resultat.antalrätt DESC, kunder.username ASC");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
}
?>
</div>
</body>
</html>