-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassEdit.php
More file actions
120 lines (117 loc) · 6.2 KB
/
Copy pathclassEdit.php
File metadata and controls
120 lines (117 loc) · 6.2 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
<?php
include('utils/session.php');
if (!isset($_SESSION['login_user'])) {
header("location: index.php"); // Redirecting To Home Page
}
?>
<!DOCTYPE html>
<html>
<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">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- MDBootstrap CDN Start -->
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.8.2/css/mdb.min.css" rel="stylesheet">
<!-- JQuery -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.4/umd/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.8.2/js/mdb.min.js"></script>
<!-- MDBootstrap CDN END -->
<title>Classes</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<?php
require_once("classesDataClass.php");
$classId = $className = $classNumericName = $section = $teacherId = '';
if ($_SERVER["REQUEST_METHOD"] == "GET") {
// TODO: Write Get Action to display record and fill the fields for editing
$classId = $_GET['id'];
$classesData = new classesData();
$cdcObj = $classesData->GetSingleRecord($classId);
if ($cdcObj != null) {
$classId = $cdcObj->classId;
$className = $cdcObj->className;
$classNumericName = $cdcObj->classNumericName;
$section = $cdcObj->section;
$teacherId = $cdcObj->teacherId;
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// TODO: Write code to Update records based on posted back fields
$classesData = new classesData();
$classesData->Update($_POST['classId'], $_POST['className'], $_POST['classNumericName'], $_POST['teacher'], $_POST['section']);
}
?>
</head>
<body>
<?php
include('utils/header.php');
require_once("utils/config.php");
$connection = mysqli_connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
if (mysqli_connect_error()) {
die(mysqli_connect_error());
} else { }
?>
<div class="container d-flex" id="wrapper">
<?php include("utils/sidebar.php") ?>
<div id="main-content">
<div class="h1 text-center">CLASS EDIT</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<form action="" method="post">
<input type="hidden" name="classId" id="classId" value="<?= $classId ?>">
<div class="form-group">
<label for="className">Class Name</label>
<input type="text" name="className" class="form-control" id="className" placeholder="One" value="<?= $className ?>">
</div>
<div class="form-group">
<label for="classNumericName">Class Numeric Name</label>
<input type="text" name="classNumericName" class="form-control" id="classNumericName" placeholder="1" value="<?= $classNumericName ?>">
</div>
<div class="form-group">
<label for="section">Section</label>
<input type="text" name="section" class="form-control" id="section" placeholder="A" value="<?= $section ?>">
</div>
<div class="form-group">
<label for="teacher">Teacher</label>
<select name="teacher">
<?php
$sql = "SELECT teacherId, FirstName, LastName FROM teacher";
$result = mysqli_query($connection, $sql);
$select = "";
$tId = "";
$name = "";
while ($row = mysqli_fetch_assoc($result)) {
if ($row['teacherId'] == $teacherId)
$tId = $row['teacherId'] . '" selected';
else
$tId = $row['teacherId'];
$name = $row['FirstName'] . " " . $row['LastName'];
$select .= '<option value="' . $tId . '"> ' . $name . '</option>';
}
echo $select;
?>
</select>
</div class="form-group">
<div>
<button type="submit" class="btn btn-primary">Edit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>