-
Notifications
You must be signed in to change notification settings - Fork 0
/
department.php
177 lines (157 loc) · 4.37 KB
/
department.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
<!DOCTYPE html>
<html>
<head>
<title>Department</title>
<link rel="stylesheet" type="text/css" href="css/department.css">
<script type="text/javascript">
function conformDelete(){
if (confirm("Are you sure you want to delete?")) {
location.href='DeleteSubject.php?i='+arguments[0]+'';
}else{
location.href='department.php';
}
}
</script>
</head>
<body>
<!-- -------------------------------------------------------->
<?php include "adminSlide.php"; ?>
<div style="margin-left: 220px; margin-top: 60px;margin-bottom: 40px;">
<div class="container">
<p><b><u>Manage Subject</u></b></p>
</div>
<!-- ---------------------------------------------------------- -->
<div class="container">
<hr class="hr">
</div>
<div class="backgr">
<div class="it">
<label><a href="department.php">BE-Information Technology</a></label>
</div>
<div class="com">
<label ><a href="depcomputer.php">BE-Computer</a></label>
</div>
<div class="sof">
<label ><a href="depsoftware.php">BE-Software</a></label>
</div>
</div>
<div class="container">
<hr class="hr">
</div>
<!-- -------------------------------------------------------------->
<div class="IT">
<form action="department.php" method="POST">
<br>
<div id="lab" >
<label>Add Subject : </label>
<input type="text" name="subject" required>
<input type="text" name="department" value="IT" hidden>
<label>semester : </label>
<input type="number" name="sem" required>
</div>
<div style="margin-left: 50%;margin-top: 10px;" >
<button type="submit" name="OK">OK</button>
</div>
</form>
</div>
<!-- --------------------------------------------------------------->
<?php
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "dbphp";
$con = mysqli_connect($host,$dbusername,$dbpassword,$dbname);
if (!$con) {
# code...
die("connection fail....".mysqli_connect_error());
}
$sql=" ";
if (isset($_POST['OK'])) {
$dep=$_POST['department'];
$sub=$_POST['subject'];
$sem=$_POST['sem'];
$insert="INSERT into subject(department,subject,semester) values('$dep','$sub','$sem')";
if(mysqli_query($con,$insert)){
?>
<script>
alert('successfully save');
window.open('department.php','_self');
</script>
<?php
}else{
?>
<script>
alert('Error--!!!');
window.open('department.php','_self');
</script>
<?php
}
}
?>
<!-- ------------------------------------------------------------- -->
<br>
<!-- ------------------------------------------------------------- -->
<div class="itborder">
<table style="width: 1000px;">
<tr>
<td style="width: 500px;">
<div>
<label><b><u>Semester : 1</u></b></label>
</div>
</td>
<td>
<div>
<label><b><u>Semester : 2</u></b></label>
</div>
</td>
</tr>
<tr>
<td>
<?php
$sql="select * from subject where department LIKE 'IT' AND semester='1' ";
$result_set = mysqli_query($con,$sql);
$count=1;
if (mysqli_num_rows($result_set)>0) {
while($row = mysqli_fetch_array($result_set)){
$id=$row['id'];
$sub=$row['subject'];
?>
<div style="margin-left: 20px;font-size: 20px;">
<?php echo $count;?> .
<label style="margin-left: 20px;font-size: 20px;"><?php echo $sub; ?>
</label>
<button name="delete" value="delete" onclick="conformDelete(<?php echo $id;?>,1)" style="font-size: 15px;float: right;margin-right: 150px;">-Delete-</button>
</div>
<?php
$count++;
}
}
?>
</td>
<td>
<?php
$sql="select * from subject where department LIKE 'IT' AND semester='2' ";
$result_set = mysqli_query($con,$sql);
$count=1;
if (mysqli_num_rows($result_set)>0) {
while($row = mysqli_fetch_array($result_set)){
?>
<div style="margin-left: 20px;font-size: 20px;">
<?php echo $count;?> .
<label style="margin-left: 20px;font-size: 20px;"><?php echo $row['subject']; ?>
</label>
<button name="delete" value="delete" onclick="conformDelete(<?php echo $row['id'];?>,1)" style="font-size: 15px;float: right;margin-right: 150px;">-Delete-</button>
</div>
<?php
$count++;
}
}
?>
</td>
</tr>
</table>
</div>
<!-- ------------------------------------------------------------ -->
</div>
</body>
</html>