-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditCourseAdmin.php
More file actions
143 lines (125 loc) · 3.29 KB
/
editCourseAdmin.php
File metadata and controls
143 lines (125 loc) · 3.29 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
<?php
include "link.php";
$query = "SELECT * FROM course C, professor P WHERE P.idNumber = C.profID";
$result = $mysqli->query($query);
echo '<table class="table table-striped">
<tr>
<td>CourseName</td>
<td>TeacherName</td>
<td>Classroom</td>
<td>Capacity</td>
<td>Credit</td>
<td>Department</td>
<td>Obligatory</td>
<td>CourseYear</td>
<td>CourseTime</td>
<td>CourseID</td>
<td>Delete</td>
</tr>';
while ($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>" . $row['courseName'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['classroom'] . "</td>";
echo "<td>" . $row['capacity'] . "</td>";
echo "<td>" . $row['credit'] . "</td>";
echo "<td>" . $row['department'] . "</td>";
if($row['obligatory'])echo "<td>obligatory</td>";
else echo "<td>not obligatory</td>";
echo "<td>" . $row['courseYear'] . "</td>";
echo "<td>" . $row['courseTime'] . "</td>";
echo "<td>" . $row['courseID'] . "</td>";
echo '<td><a class="btn btn-danger" href=/course.php?webNo=2&courseID='
.$row['courseID'].'>Delete It'.'</a></td>';
echo "</tr>";
}
echo '</table>';
//delete the course
if(!empty($_GET['courseID'])){
$courseID = $_GET['courseID'];
//delete course
$query = "DELETE FROM course WHERE courseID='$courseID'";
$result = $mysqli->query($query);
//delete enroll
$query = "DELETE FROM enroll WHERE courseID='$courseID'";
$result = $mysqli->query($query);
}
?>
<form method="post" action="course.php?webNo=2">
<label>Select Course</label>
<select name="courseID">
<?php
$query = "SELECT * FROM course";
$result = $mysqli->query($query);
while ($row = $result->fetch_assoc()){
echo"<option>";
echo $row['courseID']. '-' . $row['courseName'];
echo"</option>";
}
?>
</select>
<span class="" id=""></span>
<label>Add/Delete</label>
<select name="choose">
<option name="add">Add</option>
<option name="delete">Delete</option>
</select>
<span class="" id=""></span>
<div>
<button class="btn btn-primary">Choose Course</button>
</div>
<span class="help-block" id=""></span>
</form>
<?php
if(!empty($_POST['courseID']) && !empty($_POST['choose'])){
$courseID = explode("-", $_POST['courseID']);
$courseID = $courseID[0];
$choose = $_POST['choose'];
echo $courseID;
echo $choose;
if($choose == 'Add'){
?>
<form method="post" action=<?php echo 'add.php?courseID=' .$courseID?> >
<label>Select Student</label>
<select name="stdID">
<?php
$query = "SELECT * FROM student";
$result = $mysqli->query($query);
while ($row = $result->fetch_assoc()){
echo"<option>";
echo $row['idNumber']. '-' . $row['name'];
echo"</option>";
}
?>
</select>
<div>
<button class="btn btn-success">Add Student</button>
</div>
<span class="help-block" id=""></span>
</form>
<?php
}
else if($choose == 'Delete'){
?>
<form method="post" action=<?php echo 'delete.php?courseID=' .$courseID?> >
<label>Select Student</label>
<select name="stdID">
<?php
$query = "SELECT * FROM student";
$result = $mysqli->query($query);
while ($row = $result->fetch_assoc()){
echo"<option>";
echo $row['idNumber']. '-' . $row['name'];
echo"</option>";
}
?>
</select>
<div>
<button class="btn btn-danger">Delete Student</button>
</div>
<span class="help-block" id=""></span>
</form>
<?php
}
}
?>