-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcourseQuery.php
More file actions
48 lines (42 loc) · 1.61 KB
/
Copy pathcourseQuery.php
File metadata and controls
48 lines (42 loc) · 1.61 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
<?php
require "../verifyUser.php";
require "../ConnectDB.php";
$cid=$_POST["cid"];
$did=$_POST["did"];
if ($cid!="")
{
$result=mysql_query("SELECT CNAME FROM COURSE WHERE CID='$cid'");
$row=mysql_fetch_array($result);
if (empty($row))
{
echo '<script>alert("The course '.$tid.' doesn\'t exist!");</script>';
exit;
}
echo "<div class='row'><h4 class='col-sm-6'>Course: $cid $row[CNAME]</h4>";
echo "<div class='col-sm-offset-1 col-sm-2'><a class='btn btn-primary' href='courseInfo.php?cid=$cid'>Edit</a></div>";
echo "<div class='col-sm-2'><button class='btn btn-danger' onclick='deleteCourse()'>Delete</button></div></div>";
require "../teacher/studentList.php";
}else
if ($did!="")
{
$result=mysql_query("SELECT DNAME FROM DEPARTMENT WHERE DID='$did'");
$row=mysql_fetch_array($result);
if (empty($row))
{
echo '<script>alert("The department '.$did.' doesn\'t exist!");</script>';
exit;
}
echo "<h4>Department: $did $row[DNAME]</h4>";
$result=mysql_query("SELECT CID, CNAME, CREDIT, CNUM, TNAME FROM COURSE, TEACHER WHERE DID='$did' AND COURSE.TID=TEACHER.TID GROUP BY CID ASC");
echo '<table class="table table-striped">';
echo '<thead><tr><th>#</th><th>Course Id</th><th>Course Name</th><th>Credit</th><th>Available</th><th>Teacher</th></tr></thead><tbody>';
$num=0;
while ($row=mysql_fetch_array($result))
{
++$num;
echo "<tr><td>$num</td><td>$row[CID]</td><td>$row[CNAME]</td><td>$row[CREDIT]</td><td>$row[CNUM]</td><td>$row[TNAME]</td></tr>";
}
echo '</tbody></table>';
}
else echo '<script>alert("Either course Id or department Id is required!");</script>';
?>