Show sourcecode
The following files exists in this folder. Click to view.
adminlogin.php
createtables.php
createtest.php
dbconnection.php
index.php
kundsida.php
result.php
test.php
result.php
76 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
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
include('dbconnection.php');
session_start();
$warningMsg = "";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
table{
border: 1px black solid;
}
td{
width: 100px;
}
tr{
width: 100px;
}
th{
width: 100px;
text-align: center;
background-color: grey;
}
</style>
</head>
<body>
<nav>
<a href="index.php">Login</a> <br>
<a href="result.php">Resultat</a> <br>
<a href="kundsida.php">Kundsida</a> <br>
<a href="adminlogin.php">Admin</a>
</nav>
<?php
try{
$sql = "SELECT * FROM testresults
ORDER BY testid, amountcorrect";
$stmt = $dbconn->prepare($sql);
$data = array();
$stmt->execute($data);
$output = "<h1>Tester!</h1><table>
<tr>
<th> Test </th>
<th> Userid </th>
<th> Antal rätt </th>
<th> Datum för Test </th>
</tr>
";
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
$output .= "<tr>".
"<td>".htmlentities($res['testid'])."</td>".
"<td>".htmlentities($res['userid'])."</td>".
"<td>".htmlentities($res['amountcorrect'])."</td>".
"<td>".htmlentities($res['test_date'])."</td>".
"</tr>";
}
$output .= "</table>";
echo "$output";
}
catch(PDOException $e)
{
echo $sql . "<br />" . $e->getMessage();
}
$dbconn = null;
?>
</html>
</body>
</html>