-
Notifications
You must be signed in to change notification settings - Fork 0
/
caursereg (2).php
264 lines (251 loc) · 5.76 KB
/
caursereg (2).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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
session_start();
include("includes/connect.php");
if (!$_SESSION['deanp']) {
header("location:index.php");
}
?>
<?php
$b="SELECT *FROM teachers";
$de=mysql_query($b);
$e=1;
while ($row=mysql_fetch_array($de)) {
$id=$row['t_id'];
}
$e++;
?>
<?php
$s="SELECT *FROM students";
$k=mysql_query($s);
while ($row=mysql_fetch_array($k)) {
$ids=$row['s_id'];
}
?>
<?php
$q="SELECT *FROM departement";
$k=mysql_query($q);
while ($row=mysql_fetch_array($k)) {
$idd=$row['d_dpt'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo"Course registration"?></title>
<?php
include("includes/banner.php");
include("includes/header.php");
?>
<link rel="stylesheet" type="text/css" href="css/caursereg.css">
<script src="java/jquery.js"></script>
<script src="java/jquery-ui.js"></script>
<link rel="stylesheet"href="java/jquery-ui.css">
<script type="text/javascript">
var a;
$(function(){
$(".up").click(function(){
//alert($(this).val());
a=$(this).val();
});
$("#frm").submit(function(e){
e.preventDefault();
var b=("#cname").val();
var c=("#acrony").val();
var d=("#clid").val();
var e=("#tid").val();
var f=("#did").val();
$.post("updatecourse.php",{id:a,cname:b,acrony:c,clid:d,tid:e,did:f},function(data){
alert(data);
});
});
});
</script>
<style type="text/css">
#fter{background-color: #5da1a7;height:60px;margin-top: 1px;font-family:corbel;text-align: center;
padding-top: 3px;position: fixed;z-index: 1px;width: 1200px;
}
#commented{
width:100%;height: 100%;background-color: rgba(8,7,5,.7);top: 0px;position: fixed;left: 0px;
}
#coco{height: 25%;width: 50%;background-color: white;
margin-left: 25%;margin-top: 12%;overflow-y:scroll;
}
</style>
<script>
$(document).ready(function(){
$("#menuico").click(function(){
$("#menu").hide(500);
});
$("#menuico").click(function(){
$("#menu").show(1000);
});
});//this hiding is running but no content to be hidded or showed
</script>
</head>
<body>
<div id="indcontent">
<div class="blankspace"><!--this is the division of student links-->
<div id="data">
<form method="POST">
<table>
<tr><td>CaurseName</td><td><input type="text" name="cname" pattern="[A-Za-z']{2,30}"
placeholder="Enter caurse name" size="30" id="cname" required></td></tr>
<tr><td>Acronym</td><td>
<input type="text" required pattern="[A-Za-z']{1,30}" placeholder="Enter acronym " size="30" name="acronym" id="acrony"></td></tr>
<tr><td>Class</td>
<td>
<select name="clid" id="clid" required>
<option value="">--Select--</option>
<?php
$fd=mysql_query("SELECT *FROM classes");
while ($rowd=mysql_fetch_array($fd)) {
?>
<option value="<?php echo $rowd['cl_id'];?>"><?php echo $rowd['classname'];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr><td>Teacher</td>
<td>
<select name="tid" id="tid" required>
<option value="">--Select--</option>
<?php
$fd=mysql_query("SELECT DISTINCT *FROM teachers");
while ($rowd=mysql_fetch_array($fd)) {
?>
<option value="<?php echo $rowd['t_id'];?>">
<?php echo $rowd['firstname']." ".$rowd['lastname'];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr><td>Departement</td>
<td>
<select name="did" id="did" required>
<option value="">--Select--</option>
<?php
$fd=mysql_query("SELECT DISTINCT *FROM departement");
while ($rowd=mysql_fetch_array($fd)) {
?>
<option value="<?php echo $rowd['d_dpt'];?>"><?php echo $rowd['dpt_name'];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr><td>Maximum</td><td>
<input type="text" name="max" placeholder="Enter caurse name" size="30" id="max"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" value="Save" name="save"></td></tr>
</form>
</table>
<table border="1">
<tr><td>CaurseName</td><td>Acronym</td><td>Maximum</td><td colspan="3" align="center">Action</td></tr>
<?php
$srq=mysql_query("SELECT *FROM caurses");
if ($srq) {
$o=1;
while ($row=mysql_fetch_array($srq)) {
?>
<tr>
<td><?php echo $row['coursename'];?></td>
<td><?php echo $row['acronym'];?></td>
<td><?php echo $row['maximum'];?></td>
<td>
<a onclick="dela('<?= $row['c_id'];?>','<?= $row['coursename'];?>');">
Delete</a>
<td>
<button class="buton" value="<?= $row['c_id']?>"><a>Update</a></button>
</tr>
<script type="text/javascript">
$(document).ready(function(e){
$("#load").dialog({
autoOpen:false,
modal:true,
width:400,
position:{
my:"center top",
at:"center top",
of:".blankspace",
}
});
$(".buton").click(function(e){
e.preventDefault();
//alert($(this).val());
var id=$(this).val();
$("#load").dialog("open");
$("#load").load('updatecourse.php?idcau='+id+'');
});
});
</script>
<?php
}$o++;
}
?>
<script type="text/javascript">
function dela(ids,caursenames){
var sinfo=confirm('Are you sure to Delete '+caursenames+'?');
if (sinfo==true) {
window.location='deletecaurse.php?idse='+ids;
}
}
</script>
<div id="back">
<div id="inside">
<!--this is the contents for updates of caurses-->
</div>
</div>
</table>
<script src="java/jquery-ui.js"></script>
<link rel="stylesheet"href="java/jquery-ui.css">
<script type="text/javascript">
</script>
</div><!--ending data division-->
</div><!--ending linkspace-->
</div><!--ending blank space-->
<div id="load"></div>
<div id="fter">
<h3>Allright reserved © by Mucyo Rene</h3>
</div>
</body>
</html>
<?php
if (isset($_POST['save'])) {
$ff=$_POST['cname'];
$f=mysql_real_escape_string($ff);
$cc=$_POST['acronym'];
$c=mysql_real_escape_string($cc);
$ii=$_POST['max'];
$i=mysql_real_escape_string($ii);
$cat_mx=$i/2;
$exam_mx=$i/2;
$ww=$_POST['tid'];
$w=mysql_real_escape_string($ww);
$mm=$_POST['did'];
$m=mysql_real_escape_string($mm);
$nn=$_POST['clid'];
$n=mysql_real_escape_string($nn);
$ex=mysql_query("INSERT INTO caurses SET
c_id=null,
coursename='$f',
acronym='$c',
maximum='$i',
t_id='$w',
d_id='$m',
cl_id='$n'") or die(mysql_error());
if ($ex) {
?>
<script type="text/javascript">
alert("inserted");
</script>
<?php
}else{
?>
<?php
}
}
?>