-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_semester.php
59 lines (44 loc) · 1.35 KB
/
add_semester.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
<html>
<head>
<title>Semester Control Panel</title>
</head>
<body>
<h1>WMFO Semester Control Panel</h1><br>
<form action="./add_semester.php" method="post">
<table border="3">
<tr><td>Semester Name: </td>
<td><input name="SemesterName"></td></tr>
<tr><td><input type="Submit" value="Add Semester"></td></tr>
</table>
</form>
<hr>
<h1>Current Semesters</h1><br>
<?php
include 'commlib.php';
$conn = mysql_init();
if (isset($_POST['SemesterName']))
{
add_semester($conn, $_POST['SemesterName']);
}
if (isset($_REQUEST['semesterToDelete']) )
{
delete_semester($conn, $_REQUEST['semesterToDelete']);
}
//Make a table to show the current semesters
echo "<table border=3><tr><th>Semester Name</th><th>Creation Time</th><th>Shows</th><th>Delete</th></tr>\n";
$stmt = $conn->prepare("SELECT ID,TITLE,CREATION_TIME FROM SEMESTER ORDER BY CREATION_TIME DESC");
$stmt->execute();
$stmt->bind_result($id, $title, $time);
while ($stmt->fetch())
{
printf("<tr><td>%s</td><td>%s</td>\n", $title, $time);
printf("<td><a href='./add_show?semester=%s'>View/Add</a></td>\n", $id);
printf("<td><form action='./add_semester?semesterToDelete=%s' method='post' onsubmit=\"return confirm('Are you sure you want to delete %s?')\"><input type=\"submit\" value=\"delete\"></form></td></tr>\n", $id, $title);
}
$stmt->close();
$conn->close();
?>
</table>
<?php footer(); ?>
</body>
</html>