-
Notifications
You must be signed in to change notification settings - Fork 0
/
faculty.php
229 lines (204 loc) · 10.4 KB
/
faculty.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
<?php session_start();?>
<!DOCTYPE html >
<html >
<head>
<title>Canvas - Administrator </title>
<link href="admin_css/styles.css" rel="stylesheet" type="text/css" media="all" />
<link href="admin_css/violine.css" rel="stylesheet" type="text/css" media="all" />
</head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#addnew").click( function() {
$("#formadd").fadeIn();
});
$("#edit2").click( function() {
$("#form2").fadeIn();
});
});
</script>
<?php include("session/DBConnection.php");
include("session/session.php");
$error ="";
?>
<body>
<?
include("admindata.php");
?>
<!-- /Cols > 1 -->
<div class="col_3 design">
<div align="left" >
<table width="800" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td align="left" style="background: #333; border: 1px solid #331;color:#fff; font-weight: bold; width: 400px;"><strong> Faculty Members</strong></td>
</tr>
<tr>
<?php
$result = mysql_query("SELECT * FROM members WHERE confirmation = '1' AND type = 'Faculty' ORDER BY firstname ASC LIMIT 15");
while($row = mysql_fetch_array($result))
{?>
<td align="center" bgcolor="#FFFFFF" width="250"><a href="memberinfo2.php?id=<?php echo $row["member_id"]; ?>" valign="top"><img style="padding-top: 15px; border-width: 0px; margin-left: 20px;" align="left" width=50 height=50 alt="Unable to View" src="<?php echo $row["image"]; ?> "></a><br />
<span style="text-transform:capitalize; margin-right: 600px; text-decoration: none;"><a href="memberinfo2.php?id=<?php echo $row["member_id"]; ?>" valign="top"><?php echo $row['firstname'] . " " . $row['lastname']; ?></a></span></td>
</tr>
<?php
}
?>
</table><br />
<div style="border: 1px solid #333; width: 481px; height: 400px; margin-top: -68px; margin-left: 280px; background-color: #333">
<div><span style="color: #FFFF00; font-size: 14px; font-weight: bold; padding-left: 200px;">Maintenance</span><br />
<br /><span style="padding-left: 30px; "><input style="background-color:#FFFFCC; border: 1px solid #333; width: 160px;" id="addnew" name="addnew" type="button" value="Add New Faculty" />
<div align="right">
<form action="faculty.php" method="post" style="width: 300px; margin-top: -25px; padding-right:10px;">
<input type="text" name="id_no" value="Enter ID No." onclick="this.value='';" />
<input name="search" type="submit" value="Search" /></form>
<?php
if(isset($_POST['search'])){
$id_no = $_POST['id_no'];
$results="SELECT * FROM faculty WHERE id_no = '$id_no' ";
$result=mysql_query($results);
if(mysql_num_rows($result) <= 0)
{
echo '<div align="left" style="margin-left: 200px; margin-top: 100px; font-size: 18px;">No results</div>';
echo '<div align="left" style="margin-left: 200px; margin-top: 50px; font-size: 18px;"><a href="faculty.php"><input type="submit" value="OK" name="OK" /></a></div>';
} else {
while($row=mysql_fetch_array($result)){
?><div align="left">
<ul>
<br />
<span class='style29'>Firstname: </span><span class='style28' style='padding-left:30px;'><?php echo $row["firstname"]; ?></span><br />
<span class='style29'>Lastname: </span><span class='style28' style='padding-left: 30px;'><?php echo $row['lastname']; ?></span><br />
<span class='style29'>Course Code: </span><span class='style28' style='padding-left: 5px;'><?php echo $row['course']; ?></span><br />
<span class='style29'>Status: </span><span class='style28' style='padding-left: 56px;'><?php echo $row['status']; ?></span><br />
<span class='style29'>Gender: </span><span class='style28' style='padding-left: 49px;'><?php echo $row['gender']; ?></span><br /><br />
<form method="post" action="faculty.php">
<input type="hidden" value=<?php echo $row['id_no']; ?> name="id_no" />
<a href="faculty.php?action=edit&id=<?php echo $row['faculty_id']; ?>"><input type="submit" value="Edit" style="background-color:#F7F8D6; font-weight: bold; border: 1px solid #333; width: 100px;" /></a>
<input type="submit" name="delete" value="Delete" style="background-color:#F7F8D6; font-weight: bold; border: 1px solid #333; width: 100px;" />
<a href="faculty.php"><input type="submit" value="Cancel" style="background-color:#F7F8D6; font-weight: bold; border: 1px solid #333; width: 100px;" /></a>
</form>
</ul>
</div><?php
}
}
}
if(isset($_POST['delete'])){
$id_no = $_POST['id_no'];
$sql = "DELETE FROM faculty WHERE id_no='$id_no'";
$result = mysql_query($sql);
}
?>
</div>
</span><br />
<?php
include('session/DBConnection.php');
if (isset($_POST['add'])) {
if (!$_POST['id_no']|
!$_POST['firstname']|
!$_POST['lastname']|
!$_POST['gender']|
!$_POST['course']|
!$_POST['status']){
die('Please complete all the required feilds!');
}
if (!get_magic_quotes_gpc()) {
$_POST['id_no'] = addslashes($_POST['id_no']);
}
$idcheck = $_POST['id_no'];
$check3 = mysql_query("SELECT * FROM members WHERE id_no = '$idcheck'")
or die(mysql_error());
$check4 = mysql_num_rows($check3);
if ($check4 != 0) {
die('Sorry, the ID No. '.$_POST['id_no'].' is already in use!' . " " . 'or' . " " .'INVALID ID No.!<br />'. " " . " " .'Please try again..<br /><a href="faculty.php"><input type="submit" value="OK" name="OK" /></a>' );
}
$_POST['id_no'] = ($_POST['id_no']);
$insert = "INSERT INTO faculty SET id_no='$_POST[id_no]', firstname='$_POST[firstname]', lastname='$_POST[lastname]', gender='$_POST[gender]', course='$_POST[course]', status='$_POST[status]'";
$add_member = mysql_query($insert);
header("location: faculty.php");
exit();
}
?>
<?php
include ("session/DBConnection.php");
if (isset($_GET['id'])) {
$user = $_GET['id'];
$query = mysql_query("SELECT * FROM faculty WHERE faculty_id = '$user'") or die (mysql_error());
$display = mysql_fetch_array($query);
echo '<form action="faculty.php?action=edit&id='.$display['faculty_id'].'" method="POST" style="width: 443px; margin-left: 20px;">';
echo "Firstname: <span style='padding-left:10px; text-transform: capitalize; font-weight: bold; color: #FFFF33;'>" . $display["firstname"] . "</span><br />";
echo "Lastname: <span style='padding-left: 10px; text-transform: capitalize; font-weight: bold;color: #FFFF33;'>" . $display['lastname'] . "</span><br />";
echo 'Status: <select name="status" style="margin-top: 10px; width: 150px; margin-left: 77px; text-transform: capitalize;">
<option value="-1" selected="selected">-Select Status-</option>
<option>Regular</option>
<option>Part Time</option>
</select><br />';
echo 'Gender: <select name="gender" style="width: 150px; margin-top: 10px; margin-left: 70px; text-transform: capitalize;">
<option value="-1" selected="selected">-Select Gender-</option>
<option>Female</option>
<option>Male</option>
</select><br />';
echo 'Course Code: <select name="course" style="margin-top: 10px; width: 150px; margin-left: 38px; text-transform: capitalize;">
<option value="-1" selected="selected">-Select Course Code-</option>
<option>..</option>
<option>..</option>
<option>..</option>
<option>..</option>
</select><br /><br />';
echo '<input type="submit" name="edit" value="Submit" />';
echo '<a href="faculty.php"><input type="submit" name="cancel" value="Cancel" /></a>';
echo '<input type="hidden" name="id_no" value="'.$display['id_no'].'" />';
echo '</form>'; } ?>
<?php
if(isset($_POST['edit'])){
$user = $_GET['id'];
$status = $_POST['status'];
$course = $_POST['course'];
{
$sql2 = "UPDATE faculty SET status='$status', course='$course' WHERE faculty_id='$user'";
$result2 = mysql_query($sql2);
}
// if successful redirect to delete_multiple.php
if($result2){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=faculty.php\">";
}
} ?>
<div id="formadd" style="display:none;margin-left: 40px; border: 1px solid #999999; width: 400px; ">
<form action="faculty.php" method="post">
<span style="text-transform:capitalize; color: #66FF00; text-align: left;">
<label style=" padding-left: 5px;">Faculty's ID No. : <input name="id_no" type="text" style="margin-top: 10px; margin-left: 23px; text-transform: capitalize;"/></label><br />
<label style=" padding-left: 5px;">Firstname: <input type="text" style="margin-top: 10px; margin-left: 55px; text-transform: capitalize;" name="firstname"></label><br />
<label style=" padding-left: 5px;">Lastname: <input name="lastname" type="text" style="margin-top: 10px; margin-left: 55px; text-transform: capitalize;"/></label><br />
<label style=" padding-left: 5px;">Gender: <select name="gender" style="width: 150px; margin-top: 10px; margin-left: 70px; text-transform: capitalize;">
<option value="-1" selected="selected">-Select Gender-</option>
<option>Female</option>
<option>Male</option>
</select> </label><br />
<label style=" padding-left: 5px;">Course: <select name="course" style="margin-top: 10px; width: 150px; margin-left: 70px; text-transform: capitalize;">
<option value="-1" selected="selected">-Select Course-</option>
<option>..</option>
<option>..</option>
<option>..</option>
<option>..</option>
</select></label><br />
<label style=" padding-left: 5px;">Status: <select name="status" style="margin-top: 10px; width: 150px; margin-left: 77px; text-transform: capitalize;">
<option value="-1" selected="selected">-Select Status-</option>
<option>Regular</option>
<option>Part Time</option>
</select></label><br />
<input style="margin-top: 20px; margin-left: 150px;" type="submit" name="add" value="Add to records" />
<a href="faculty.php"><input type="submit" name="cancel" value="Cancel" /></a>
<br /><br /></span></form>
</div></div>
<br />
<br />
<br />
</div>
</div>
</div>
<!-- /Cols > 3 -->
<br class="clear" />
</div>
<!-- /content of main -->
</div>
<!-- /MAIN -->
</body>
</html>