-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcourse-info.php
More file actions
151 lines (121 loc) · 4.32 KB
/
Copy pathcourse-info.php
File metadata and controls
151 lines (121 loc) · 4.32 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Courses</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">
<link href="https://fonts.googleapis.com/css?family=Be+Vietnam:400,600,800&display=swap" rel="stylesheet">
</head>
<body>
<?php
$servname = "localhost";
$conn = new mysqli($servname, "root","", "college_db");
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
?>
<div class="page-container">
<div class="user-label rect-circ">
<span class="rect-circ">HEAD</span>
</div>
<div class="btn-logout rect-circ" onClick="goBack()">
<span class="rect-circ">BACK</span>
<div class="rect-circ"><-</div>
</div>
<div class="dept-label">
<?php
$sql = "SELECT DEPARTMENT.DeptName
FROM INSTRUCTOR, DEPARTMENT
WHERE INSTRUCTOR.InstructorID = ".$_SESSION["userid"].
" AND INSTRUCTOR.DeptNo = DEPARTMENT.DeptNo";
$res = $conn->query($sql);
if ($res->num_rows > 0) {
while ($row = $res->fetch_assoc()) {
echo "<span>".$row['DeptName']."</span>";
}
}
?>
</div>
<form class="Course_page-container" method="post" action="<?php htmlspecialchars($_SERVER['PHP_SELF']) ?>">
<input type="submit" value="SUBMIT" class="btn-submit rect-circ"/>
<?php
$courses = array();
$sql = "SELECT COURSE.CourseID, COURSE.CourseName, COURSE.InstructorID FROM COURSE
WHERE COURSE.DeptNo = ".$_SESSION["deptid"]." ORDER BY COURSE.CourseID";
$res = $conn->query($sql);
if ($res->num_rows > 0) {
while ($row = $res->fetch_assoc()) {
array_push($courses,
array($row['CourseID'], $row['CourseName'], $row['InstructorID']));
}
}
for ($i = 0; $i < COUNT($courses); $i++) {
$sql = "UPDATE COURSE SET InstructorID = '";
$sql .= isset($_POST['insid'.$i]) ? $_POST['insid'.$i] : '';
$sql .= "', CourseName = '";
$sql .= isset($_POST['crsnm'.$i]) ? $_POST['crsnm'.$i] : '';
$sql .= "', CourseID = '";
$sql .= isset($_POST['crsid'.$i]) ? $_POST['crsid'.$i] : '';
$sql .= "' WHERE CourseID = '".$courses[$i][0]."'";
$res = $conn->query($sql);
}
$courses = array();
$sql = "SELECT COURSE.CourseID, COURSE.CourseName, COURSE.InstructorID FROM COURSE
WHERE COURSE.DeptNo = ".$_SESSION["deptid"]." ORDER BY COURSE.CourseID";
$res = $conn->query($sql);
if ($res->num_rows > 0) {
while ($row = $res->fetch_assoc()) {
array_push($courses,
array($row['CourseID'], $row['CourseName'], $row['InstructorID']));
}
}
$inslist = array();
$sql = "SELECT * FROM INSTRUCTOR WHERE DeptNo = ".$_SESSION["deptid"];
$res = $conn->query($sql);
if($res->num_rows > 0) {
while ($row = $res->fetch_assoc()) {
array_push($inslist, array($row['InstructorID'], $row['PersonID']));
}
}
for ($i = 0; $i < COUNT($courses); $i++) {
echo
'<div class="Course_page-course">
<div class="rect-round-sm std-course-cred">
<input value="'.$courses[$i][0].'" name="crsid'.$i.'"
class="rect-round-sm std-course-id" maxlength=5/>
<input value="'.$courses[$i][1].'" name="crsnm'.$i.'"
class="rect-round-sm std-course-name" maxlength=31/>
</div>
<select class="rect-round-sm" name="insid'.$i.'" id="insid'.$i.'">';
for ($j = 0; $j < COUNT($inslist); $j++) {
if ($inslist[$j][0] == $courses[$i][2])
echo '<option selected="selected" value="'.$inslist[$j][0].'">'.$inslist[$j][0].'</option>';
else
echo '<option value="'.$inslist[$j][0].'">'.$inslist[$j][0].'</option>';
}
echo '</select>
</div>';
}
?>
</form>
</div>
<script>
function logout() {
document.cookie = "courseid" + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.cookie = "loggedin" + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.cookie = "logout=yes";
window.location.href = 'Login_page.php';
}
</script>
<script>
function goBack() {
window.location.href = 'Instructor_page1.php';
}
</script>
</body>
</html>