-
Notifications
You must be signed in to change notification settings - Fork 0
/
subjects.php
144 lines (121 loc) · 5.21 KB
/
subjects.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
<h1 class="page-header">Units/Subjects</h1>
<?php
include 'newsubject.php';
?>
<div class="col-md-8 " id="s_page">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">List of Units</h3>
</div>
<div class="panel-body">
<table id="students" class="table table-hover table-bordered">
<thead>
<tr>
<th style="width:20%">Subjects/Units</th>
<th style="width:10%">Applicable For</th>
<th style="width:10%">Description</th>
<th style="width:10%"></th>
</tr>
</thead>
<tbody>
<?php
include 'db.php';
$sql= mysqli_query($conn, "SELECT *,`FOR` as para FROM subjects Order by SUBJECT ");
while($row = mysqli_fetch_assoc($sql)) {
$count = mysqli_num_rows($sql);
?>
<tr>
<input type="hidden" id="id<?php echo $row["SUBJECT_ID"] ?>" name="id" value="<?php echo $row['SUBJECT_ID'] ?>">
<td><input id="sub<?php echo $row["SUBJECT_ID"] ?>" name="subj" type="text" style="border:0px" value="<?php echo $row['SUBJECT'] ?>" readonly></td>
<td><input id="para<?php echo $row["SUBJECT_ID"] ?>" name="subj" type="text" style="border:0px" value="<?php echo $row['para'] ?>" readonly></td>
<td><input id="des<?php echo $row["SUBJECT_ID"] ?>" name="desc" type="text" style="border:0px;width:100%" value="<?php echo $row['DESCRIPTION'] ?>" readonly></td>
<td><center><a onclick="update_subject(<?php echo $row["SUBJECT_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_subject($i){
var act,sub,para,desc,i =$i;
para = $("#para"+i).val();
$("#id").val($("#id"+i).val());
$("#sub").val($("#sub"+i).val());
$("#para").html(para);
$("#des").val($("#des"+i).val());
$("#head").html("Update Subject");
$("#btn_add").html("Update");
}
</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 Subject</h3>
<form class="" method="post">
<input type="hidden" id="id" name="id">
<div class="form-group">
<label for="sub" class="cols-sm-2 control-label">Subject</label>
<div class="cols-sm-4">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-book fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="sub" name="sub" id="sub"
style="width:200px" placeholder="Enter Subject" value="<?php if(isset($_POST['sub'])){echo $_POST['sub'];} ?>"/>
</div>
<p>
<?php if(isset($errors['sub'])){echo "<div class='erlert'><h5>" .$errors['sub']. "</h5></div>"; } ?>
</p>
</div>
</div>
<div class="form-group">
<label for="sub" class="cols-sm-2 control-label">For</label>
<div class="cols-sm-4">
<div class="input-group">
<select name="f" class="form-control" id="para1">
<option id="para"></option>
<option>All</option>
<?php
include 'db.php';
$sql = mysqli_query($conn,"SELECT * from program ORDER BY PROGRAM");
while($row=mysqli_fetch_assoc($sql)){
?>
<option value="<?php echo $row['PROGRAM'] ?>">
<?php echo $row['PROGRAM'] ?>
</option>
<?php } mysqli_close($conn); ?>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="des" class="cols-sm-2 control-label">Description</label>
<div class="cols-sm-4">
<div class="input-group">
<textarea type="text" class="form-control" name="des" id="des"
style="width:225px;height:50px" placeholder="Enter Description" value="<?php if(isset($_POST['des'])){echo $_POST['des'];} ?>"/></textarea>
</div>
<p>
<?php if(isset($errors['des'])){echo "<div class='erlert'><h5>" .$errors['des']. "</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>
<script type="text/javascript">
$(function() {
$("#students").dataTable(
{ "aaSorting": [[ 0, "asc" ]] }
);
});
</script>