-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaculty_admin.php
236 lines (164 loc) · 7.59 KB
/
faculty_admin.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php
include("connection.php");
// session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<link rel="stylesheet" href="css/style1.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<body>
<script type="text/javascript">
$(document).ready(function() {
// inspired by http://jsfiddle.net/arunpjohny/564Lxosz/1/
$('.table-responsive-stack').each(function (i) {
var id = $(this).attr('id');
//alert(id);
$(this).find("th").each(function(i) {
$('#'+id + ' td:nth-child(' + (i + 1) + ')').prepend('<span class="table-responsive-stack-thead">'+ $(this).text() + ':</span> ');
$('.table-responsive-stack-thead').hide();
});
});
$( '.table-responsive-stack' ).each(function() {
var thCount = $(this).find("th").length;
var rowGrow = 100 / thCount + '%';
//console.log(rowGrow);
$(this).find("th, td").css('flex-basis', rowGrow);
});
function flexTable(){
if ($(window).width() < 768) {
$(".table-responsive-stack").each(function (i) {
$(this).find(".table-responsive-stack-thead").show();
$(this).find('thead').hide();
});
// window is less than 768px
} else {
$(".table-responsive-stack").each(function (i) {
$(this).find(".table-responsive-stack-thead").hide();
$(this).find('thead').show();
});
}
// flextable
}
flexTable();
window.onresize = function(event) {
flexTable();
};
// document ready
});
</script>
<?php
if (isset($_GET['edit'])) {
$faculty_id = $_GET['edit'];
$update = true;
$record = mysqli_query($connection, "SELECT * FROM faculty WHERE id=$faculty_id");
if (count((array)$record))
{
$n = mysqli_fetch_array($record);
$name = $n['name'];
}
}
if (isset($_GET['delete'])) {
$faculty_id1 = $_GET['delete'];
$record = mysqli_query($connection, "DELETE FROM faculty WHERE id=$faculty_id1");
}
?>
<div class="container">
<br><br>
<!-- <nav class="navbar navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand" style="color: white;">Home</a>
</div>
</nav> <br>
-->
<div class="col-md-9 grid-margin stretch-card" style="margin-left: 10%; ">
<div class="card">
<div class="card-body">
<center><h4 class="card-title">Add Faculty</h4></center>
<form class="forms-sample" method="post" action="database_controller.php">
<input type="hidden" name="faculty_id" value="<?php echo $faculty_id; ?>">
<div class="form-group row">
<label for="exampleInputUsername2" class="col-sm-3 col-form-label">Faculty Name </label>
<div class="col-sm-9">
<input type="text" name="faculty_name" class="form-control" id="exampleInputUsername2" placeholder="Enter Name Here" value="<?php if (isset($_GET['edit'])) { echo $name ; } ?>">
</div>
</div>
<div class="form-group form-control-md row">
<label for="" class="col-sm-3 col-form-label">Department</label>
<div class="col-sm-9 " >
<select class="js-example-basic-single form-control"
name="faculty_branch" >
<option value="" disabled="disabled" selected >Select Department</option>
<option value="Chemical Engineering">Chemical Engineering</option>
<option value="Civil Engineering">Civil Engineering</option>
<option value="Computer Engineering">Computer Engineering</option>
<option value="Information Technology">Information Technology</option>
<option value="Electronics and Telecommunication Engineering">Electronics and Telecommunication Engineering</option>
<option value="Electronics Engineering">Electronics Engineering</option>
<option value="Mechanical Engineering">Mechanical Engineering</option>
</select>
</div>
</div>
<center>
<?php
if (isset($_GET['edit']) && $update == true): ?>
<button style="padding-left: 80px; padding-right: 80px;" type="submit" class="btn btn-primary mr-6" name="submit_edit_faculty" value="submit_edit_faculty">Update
</button>
<?php else: ?>
<button style="padding-left: 80px; padding-right: 80px;" type="submit" name="submit_add_faculty" value="submit_add_faculty" class="btn btn-primary mr-6" >Submit
</button>
<?php endif ?>
</center>
</form>
</div>
</div>
</div><br>
<?php
$sql_course="SELECT * FROM faculty";
$result_course=mysqli_query($connection,$sql_course) or die("Query Uncessfull");
if(mysqli_num_rows($result_course) > 0){
?>
<table class="table table-bordered table-striped table-responsive-stack" id="tableOne">
<thead class="thead-dark">
<tr>
<th scope="col">Sr. No</th>
<th scope="col">Faculty Name</th>
<th scope="col">Department</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$counter=0;
while ($row_course=mysqli_fetch_assoc($result_course)) {
$counter++;
?>
<th scope="row"><?php echo $counter ?></th>
<td><?php echo $row_course['name']; ?></td>
<td><?php echo $row_course['department']; ?></td>
<td>
<div class="row">
<div class="col-md-3">
<a href="faculty_admin.php?edit=<?php echo $row_course['id']; ?>" class="btn btn-primary btn-sm">Edit</a>
</div>
<div class="col-md-9">
<!-- <form method="post" action="database_controller.php"> -->
<a href="del/faculty_del.php?del_faculty_id=<?php echo $row_course['id']; ?>" type="button" class="btn btn-secondary btn-sm">
Delete
</a>
<!-- </form> -->
</div>
</div>
</td>
</tr>
<?php } }?>
</tbody>
</div>
</body>
</html>