-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.php
86 lines (83 loc) · 3.17 KB
/
results.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
74
75
76
77
78
79
80
81
82
83
84
85
86
<!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>Page Swapping Algorithms Stats</title>
<link rel="stylesheet" href="./css/res.css">
<link href="https://fonts.googleapis.com/css2?family=Beau+Rivage&display=swap" rel="stylesheet">
</head>
<body>
<div class="header">Paging and Page Replacement Algorithms</div>
<h1>
Results for Page Swapping Algorithms by users
</h1>
<?php
require_once "./server/config.php";
$sql = "SELECT *, name FROM stats join student on stats.srn = student.srn";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
echo "<h2>Number of registered users: " . mysqli_num_rows(mysqli_query($conn, "SELECT * FROM student")) . "</h2>";
echo "<h2>Number of times simuation saved: " . $resultCheck . "</h2>";
echo "<table>";
echo "<tr>";
echo "<th>SRN</th>";
echo "<th>Ref String</th>";
echo "<th>Process Count</th>";
echo "<th>Ram Size</th>";
echo "<th>Page Size</th>";
echo "<th>Frame Count</th>";
echo "<th>Page Count</th>";
echo "<th>FIFO Hits</th>";
echo "<th>FIFO Misses</th>";
echo "<th>LRU Hits</th>";
echo "<th>LRU Misses</th>";
echo "</tr>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['srn'] . "<br /><b>" . $row['name'] . "</b></td>";
echo "<td>" . $row['ref_string'] . "</td>";
echo "<td>" . $row['proc_count'] . "</td>";
echo "<td>" . $row['ram_size'] . "KB</td>";
echo "<td>" . $row['page_size'] . "KB</td>";
echo "<td>" . $row['frame_count'] . "</td>";
echo "<td>" . $row['page_count'] . "</td>";
echo "<td>" . $row['fifo_hits'] . "</td>";
echo "<td>" . $row['fifo_misses'] . "</td>";
echo "<td>" . $row['lru_hits'] . "</td>";
echo "<td>" . $row['lru_misses'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "No results found";
}
?>
<script>
// for each row in table, get 2nd column
document.querySelectorAll('tr').forEach(function(row) {
// get 2nd column
var col = row.querySelectorAll('td')[1];
// if 2nd column is not empty
if (col?.innerHTML) {
// get the value of 2nd column
var val = col.innerHTML;
// split by comma
var arr = val.split(',');
// put br tag after every 10 elements
for (var i = 1; i < arr.length; i++) {
if (i % 10 == 0) {
arr[i - 1] = arr[i - 1] + ' |<br /> ';
}
}
// join the array
var newVal = arr.join(' | ');
// replace the value of 2nd column
col.innerHTML = ' | ' + newVal + ' | ';
}
});
</script>
</body>
</html>