-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectedcourse.php
83 lines (83 loc) · 2.87 KB
/
selectedcourse.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
<?php
require "sessionstart.php";
require "constants.php";
echo '<meta charset="utf-8" />';
if (isset($_POST['chk'])) {
$chk = $_POST['chk'];
array_shift($chk);
if ($chk == NULL) {
echo '<script>alert("您没有选择任何课程!");</script>';
}
else {
require "connectdatabase.php";
foreach($chk as $e){
$course = mysql_query("SELECT * FROM coursechoose WHERE courseID='". $e ."' AND id='" . $user . "'");
if (mysql_fetch_array($course) != NULL) {
mysql_query("DELETE FROM coursechoose WHERE courseID='". $e ."' AND id='" . $user . "'");
$course = mysql_query("SELECT selectedNumber FROM courseinformation WHERE id='" . $e . "'");
$course = mysql_fetch_array($course);
$selected = $course['selectedNumber'] - 1;
mysql_query("UPDATE courseinformation SET selectedNumber='" . $selected . "' WHERE id='" . $e . "'");
}
}
echo '<script>alert("选中课程已删除。");</script>';
}
echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php?page=selectedcourse\">";
die("");
}
?>
<link rel="stylesheet" type="text/css" href="css/common.css" />
<div id="main" style="line-height:28px;width:95%;">
<h3>已选课程</h3>
<form action="selectedcourse.php" method="post">
<table style="border:1px solid #99F;">
<tr style="background-color:#CCC;">
<td style="width:24px;"><input style="display:none;" type="checkbox" name="chk[]" checked=1 /></td>
<td style="width:72px;">课程编号</td>
<td>课程名称</td>
<td>教师姓名</td>
<td>上课时间</td>
<td style="width:72px;">上课地点</td>
<td style="width:72px;">课程学分</td>
<td style="width:72px;">课程性质</td>
</tr>
<?php
require "connectdatabase.php";
$checklist = mysql_query("SELECT courseID FROM coursechoose WHERE id='" . $user . "' ORDER BY courseID");
$i = 0;
while ($row = mysql_fetch_array($checklist)) {
$course = mysql_query("SELECT * FROM courseinformation WHERE id='" . $row['courseID'] . "'");
$course = mysql_fetch_array($course);
$i++;
if ($i % 2 == 0) {
$highlight = " style=\"background-color:#DDD;\"";
}
else {
$highlight = " style=\"background-color:#EEE;\"";
}
echo "<tr" . $highlight . ">";
echo '<td><input class="hideborder" type="checkbox" name="chk[]" value="' . $course['id'] . '" /></td>';
echo "<td>" . $course['id'] . "</td>";
echo "<td>" . $course['name'] . "</td>";
echo "<td>" . $course['teacher'] . "</td>";
echo "<td>" . $course['time'] . "</td>";
echo "<td>" . $course['place'] . "</td>";
echo "<td>" . $course['credit'] . "</td>";
if ($course['comp'] == "1") {
$comp = "必修";
}
else {
$comp = "选修";
}
echo "<td>" . $comp . "</td>";
echo "</tr>";
}
?>
</table>
<p>
<input type="submit" value="退课" />
<input type="reset" value="重置" />
</p>
</form>
<br />
</div>