-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvisers.php
171 lines (146 loc) · 6.64 KB
/
advisers.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
<h3 class="page-header">Academic Advisers <small>section</small></h3>
<?php
include 'new_adviser.php'
?>
<div class="col-md-8 " id="s_page">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">List of Advisers</h3>
</div>
<div class="panel-body">
<table id="students" class="table table-hover table-bordered">
<thead>
<tr>
<th style="width:20%">Name</th>
<th style="width:10%">Advisory</th>
<th style="width:10%"></th>
</tr>
</thead>
<tbody>
<?php
include 'db.php';
$sql= mysqli_query($conn, "SELECT * FROM advisers left join grade on advisers.grade_id=grade.grade_id left join program
on advisers.program=program.PROGRAM where school_year='".$_GET['sy']."' ");
while($row = mysqli_fetch_assoc($sql)) {
$count = mysqli_num_rows($sql);
?>
<tr>
<input type="hidden" id="id<?php echo $row["adviser_id"] ?>" name="id" value="<?php echo $row['adviser_id'] ?>">
<input type="hidden" id="prog<?php echo $row["adviser_id"] ?>" name="id" value="<?php echo $row['PROGRAM'] ?>">
<input type="hidden" id="gid<?php echo $row["adviser_id"] ?>" name="id" value="<?php echo $row['grade_id'] ?>">
<input type="hidden" id="grade<?php echo $row["adviser_id"] ?>" name="id" value="<?php echo $row['grade'] ?>">
<input type="hidden" id="sec<?php echo $row["adviser_id"] ?>" name="id" value="<?php echo $row['section'] ?>">
<td><input id="name<?php echo $row["adviser_id"] ?>" name="" type="text" style="border:0px" value="<?php echo $row['name'] ?>" readonly></td>
<td><input id="handle<?php echo $row["adviser_id"] ?>" name="" type="text" style="border:0px" value="<?php echo $row['program'].' '.$row['grade'].'-'.$row['section'] ?>" readonly></td>
<td><center><a onclick="update_adviser(<?php echo $row["adviser_id"]?>)" class="btn btn-info" ><i class="fa fa-pencil-square" aria-hidden="true"></i> Edit</a></center></td>
</tr>
<?php
}
mysqli_close($conn);
?>
</tbody>
</table>
</div>
</div>
</div>
<script>
function update_adviser($i){
var i = $i;
$("#id").val($("#id"+i).val());
$("#name").val($("#name"+i).val());
$("#sec").val($("#sec"+i).val());
$("#g_handle").val($("#gid"+i).val());
$("#head").html('Update Adviser');
$("#btn_add").html('Update');
$("#p_handle").html($("#prog"+i).val());
$("#g_handle").html($("#grade"+i).val());
}
</script>
<div class="col-md-4" id="">
<div class="container frm-new">
<div class="row main">
<div class="main-login main-center">
<h3 id="head">Add New Adviser</h3>
<form class="" method="post">
<input type="hidden" id="id" name="id">
<input type="hidden" value="<?php echo $_GET['sy'] ?>" name="sy">
<div class="form-group">
<label for="name" class="cols-sm-2 control-label">Name</label>
<div class="cols-sm-5">
<div class="input-group">
<input type="text" class="form-control" id="name" name="name"
style="width:200px" value="<?php if(isset($_POST['name'])){echo $_POST['name'];} ?>"/>
</div>
<p>
<?php if(isset($errors['name'])){echo "<div class='erlert' id='alert'><h5>" .$errors['name']. "</h5></div>"; } ?>
</p>
</div>
</div>
<div class="form-group">
<label for="prog" class="cols-sm-2 control-label">Program Handles</label>
<div class="cols-sm-4">
<div class="input-group">
<select name='prog' id="prog" class="form-control">
<option id='p_handle'></option>
<?php
include 'db.php';
$query = mysqli_query($conn,"SELECT * From program order by PROGRAM");
while($row=mysqli_fetch_assoc($query)){
?>
<option><?php echo $row['PROGRAM'] ?></option>
<?php } ?>
</select>
</div>
<p>
<?php if(isset($errors['prog'])){echo "<div class='erlert' id='alert'><h5>" .$errors['prog']. "</h5></div>"; } ?>
</p>
</div>
</div>
<div class="form-group">
<label for="grade" class="cols-sm-2 control-label">Grade</label>
<div class="cols-sm-4">
<div class="input-group">
<select name='grade' id="grade" class="form-control cols-sm-12">
<option id='g_handle'></option>
<?php
include 'db.php';
$query = mysqli_query($conn,"SELECT * From grade order by grade_id");
while($row=mysqli_fetch_assoc($query)){
?>
<option value="<?php echo $row['grade_id'] ?>"><?php echo $row['grade'] ?></option>
<?php } ?>
</select>
</div>
<p>
<?php if(isset($errors['grade'])){echo "<div class='erlert' id='alert'><h5>" .$errors['grade']. "</h5></div>"; } ?>
</p>
</div>
</div>
<div class="form-group">
<label for="sec" class="cols-sm-2 control-label">Section</label>
<div class="cols-sm-4">
<div class="input-group">
<input type="text" class="form-control" id="sec" name="sec"
style="width:200px" value="<?php if(isset($_POST['sec'])){echo $_POST['sec'];} ?>"/>
</div>
<p>
<?php if(isset($errors['sec'])){echo "<div class='erlert' id='alert'><h5>" .$errors['sec']. "</h5></div>"; } ?>
</p>
</div>
</div>
<div class="form-group ">
<input type="reset" class="btn btn-info " id="reset" name="reset" value="Cancel">
<button class="btn btn-info" id="btn_add">Add</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$("#students").dataTable(
{ "aaSorting": [[ 0, "asc" ]] }
);
});
</script>