-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinsert.php
More file actions
213 lines (191 loc) · 5.33 KB
/
insert.php
File metadata and controls
213 lines (191 loc) · 5.33 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Insert</title>
</head>
<body>
<center>
<form action="submit.php" method="POST" name="registration">
<table cellspacing="5" cellpadding="2" bgcolor="silver" border="black">
<?php
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$conn = mysqli_connect('localhost', 'root','', 'performance_indicator');
if(!($conn))
{
echo "Connection Unuccessful";
}
$dept_id=array();
$department_name=array();
$dept=$_POST['Dept'];
#$desc=$_POST['Description'];
$sql1="SELECT * from department_table";
$result1=$conn->query($sql1);
$dept_count=$result1->num_rows;
while($row=mysqli_fetch_array($result1))
{
$dept_id[]=$row['Dept_id'];
$department_name[]=$row['Department_Name'];
if($row['Dept_id']==$dept)
{
$dept_name=$row['Department_Name'];
}
}
}
?>
<p id="demo"></p>
<tr>
<td colspan="3">
<select name="Department" id="Department">
<option value="<?php $dept ?>"><?php echo $dept_name?></option selected>
</select>
</td>
</tr>
<?php
#$dept=$_POST['Dept'];
$desc_id=array();
$description=array();
$grade_name=array();
$grade_id=array();
$unit=array();
$sql2 = "SELECT * FROM description_table where Dept_id=$dept";
$result2 = $conn->query($sql2);
$desc_count=$result2->num_rows;
while($row=mysqli_fetch_array($result2))
{
$desc_id[]=$row['Desc_id'];
$unit[]=$row['Unit_of_measurement'];
$description[]=$row['Description'];
}
$sql3= "SELECT * FROM grade_info";
$result3 = $conn->query($sql3);
$grade_count=$result3->num_rows;
while($row=mysqli_fetch_array($result3))
{
$grade_id[]=$row['Grade_ID'];
$grade_name[]=$row['GradeName'];
}
?>
<tr>
<td colspan="2">
<select name="Description" id="Description" required>
<option value="NULL">Insert values for:</option selected>
<?php
for($i=0;$i<$desc_count;$i++)
{?>
<option value="<?php echo $desc_id[$i]?>"><?php echo $description[$i]." ( in ".$unit[$i]." )"?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>
Entry Date
</td>
<td colspan="2">
<input type="date" name="Date" id="Dt" required>
<script type="text/javascript">
var today= new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy=today.getFullYear();
if(dd<10)
{
dd='0'+ dd;
}
if(mm<10)
{
mm='0'+mm;
}
today=yyyy+'-'+mm+'-'+dd;
document.getElementById("Dt").max=today;
</script>
<script type="text/javascript">
var today= new Date();
var dd = today.getDate();
var mm = today.getMonth();
var yyyy=today.getFullYear();
if(dd<10)
{
dd='0'+ dd;
}
if(mm<10)
{
mm='0'+mm;
}
today=yyyy+'-'+mm+'-'+dd;
document.getElementById("Dt").min=today;
</script>
</td>
</tr>
<tr>
<td>
Value
</td>
<td colspan="2">
<input type="number" name="obtained" required>
</td>
</tr>
<tr>
<td>
Target
</td>
<td colspan="2">
<input type="number" name="target" placeholder="Do not enter if field not applicable">
</td>
</tr>
<tr>
<td>
Grade name
</td>
<td colspan="2">
<select type="text" name="grade">
<option value=" ">Do not select if field not applicable</option>
<?php
for($i=0;$i<$grade_count;$i++)
{?>
<option value="<?php echo $grade_name[$i]?>"><?php echo $grade_name[$i]?></option>
<?php
}
?>
</td>
</tr>
<tr>
<td>
For Department specific entries
</td>
<td colspan="2">
<select type="text" name="applicable_dept">
<option value=" ">Do not select if field not applicable</option>
<?php
for($i=0;$i<$dept_count;$i++)
{
?>
<option value="<?php echo $department_name[$i]?>"><?php echo $department_name[$i]?></option selected>
<?php
}
?>
</td>
</tr>
<tr>
<td>
Reason/Remarks
</td>
<td colspan="2">
<input type="text" name="remarks" placeholder="Do not enter if field not applicable">
</td>
</tr>
<tr>
<td colspan="3" align="center">
<button type="SUBMIT">SUBMIT</button>
</td>
</tr>
</table>
</form>
<?php session_unset(); ?>
</center>
</body>
</html>