-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent.php
More file actions
118 lines (102 loc) · 3.45 KB
/
student.php
File metadata and controls
118 lines (102 loc) · 3.45 KB
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
110
111
112
113
114
115
116
117
118
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title> Student page </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="stickers.css">
</head>
<body>
<?php
include_once("connection.php");
include_once("function.php");
include_once("stickerfunctions.php");
if (!isset($_COOKIE["slogin"])) {
header('Location:login.php',true);
} else if ($_COOKIE["slogin"] == "value") {
header('Location:login.php',true);
}
$studentquery = $db_attendance->query("SELECT studentid,firstname,lastname FROM studentdata WHERE current=1 ORDER BY firstname ASC");
$studentinfo = array();
while ($student_data = $studentquery->fetch_assoc()) {
array_push($studentinfo, $student_data);
}
if(!empty($_POST['studentselect'])){
$_SESSION['id'] = $_POST['studentselect'];
header("Location: index.php"); //redirect
}
?>
<div class='classdata'>
<div id='login'>
<br />
<a class="back" href="index.php">Back</a>
<form method='post' action='<?php echo basename($_SERVER['PHP_SELF']); ?>' id='main'>
<select name='studentselect'>
<?php
foreach($studentinfo as $student){
echo "<option value=" . $student['studentid'] . ">". $student['firstname'] . " " . substr($student['lastname'], 0, 1) . "</option>";
}
?>
</select>
<input type="submit" value="Sign In" name="submit">
<?php
if (!empty($_SESSION['id'])){
echo "<span id='name'>" . idToName($_SESSION['id']) . "</span>";
} else {
echo "<span id='name'>Please sign in</span>";
}
?>
</div>
<br>
<p>
<?php
if(!empty($_SESSION['id'])){
$blackstickers = getclasses($_SESSION['id'], "blackstickers");
$greystickers = getclasses($_SESSION['id'], "greystickers");
$whitestickers = getclasses($_SESSION['id'], "whitestickers");
if (!(empty($blackstickers) && empty($greystickers) && empty($whitestickers))) {
?> <h3> Currently Stickered Classes </h3> <?php
$stickersQuery = $db_stickers->query("SELECT * FROM allottedstickers LIMIT 1");
$stickersResult = $stickersQuery->fetch_array();
$highest = max(count($blackstickers),count($greystickers),count($whitestickers));
?>
<table style="margin-top:0">
<tr>
<th class='black'>Black</th>
<th class='grey'>Grey</th>
<th class='white'>White</th>
</tr>
<?php
for ($i = 0; $i < $highest; $i++) {
?>
<tr>
<td> <?php if (!empty($blackstickers[$i])) echo "<div><a href='class.php?classid=" . $blackstickers[$i] . "'>" . classidToName($blackstickers[$i]) . "</a></div>"; ?> </td>
<td> <?php if (!empty($greystickers[$i])) echo "<div><a href='class.php?classid=" . $greystickers[$i] . "'>" . classidToName($greystickers[$i]) . "</a></div>"; ?> </td>
<td> <?php if (!empty($whitestickers[$i])) echo "<div><a href='class.php?classid=" . $whitestickers[$i] . "'>" . classidToName($whitestickers[$i]) . "</a></div>"; ?> </td>
</tr>
<?php
}
?>
<tfoot>
<tr>
<td class='black'><?php echo $stickersResult["blackstickers"] - count($blackstickers) ?> unused black</td>
<td class='grey'><?php echo $stickersResult["greystickers"] - count($greystickers) ?> unused grey</td>
<td class='white'><?php echo $stickersResult["whitestickers"] - count($whitestickers) ?> unused white</td>
</tr>
</tfoot>
</table>
<?php
} else {
?> <h3> No Stickered Classes! </h3> <?php
}
} else {
?> <h3> Please Sign In! </h3> <?php
}
?>
</p>
</div>
</form>
</body>
</html>