-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
funs.php
249 lines (220 loc) · 5.91 KB
/
funs.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
<?php
$con=mysqli_connect("http://35.225.151.155/","root","asd32145","covid_19_dbms");
if($con)
{
// echo"Connection OK";
}
else
{
echo"Connection failed";
}
if(isset( $_POST['login_submit']))
{
$email=$_POST['email'];
$password=$_POST['password'];
$quary="SELECT * FROM login_tb WHERE email_id='$email' and password='$password'";
$result=mysqli_query($con,$quary);
if(mysqli_num_rows($result)==1)
{
header("Location:adminpanel.php");
}
else
{
echo"<script>alert('Error login')</script>";
echo"<script>window.open('login.php','_self')</script>";
}
}
if(isset($_POST['update_patients']))
{
$id=$_POST['id'];
$fname=$_POST['fname'];
$age=$_POST['age'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$city=$_POST['city'];
$province=$_POST['province'];
$status=$_POST['status'];
$isolation=$_POST['isolation_id'];
$quarantine=$_POST['quarantine_id'];
$quary=" UPDATE patients SET patient_id='$id',patient_name='$fname',patient_age='$age',patient_phone='$phone',
patient_email='$email',patient_city='$city',patient_province='$province',patient_status='$status',isolation_ward_id='$isolation',quarantine_ward_id='$quarantine'
WHERE isolation_ward_id='$id';";
$result=mysqli_query($con,$quary);
if($result)
{
echo"<script>alert('Data updated Successfully')</script>";
echo"<script>window.open('viewpatients.php','_self')</script>";
}
else
{
echo"<script>alert('Data is not updated Successfully')</script>";
echo"<script>window.open('updatepatient.php','_self')</script>";
}
}
if(isset($_POST['pat_submit']))
{
$id=$_POST['id'];
$fname=$_POST['fname'];
$age=$_POST['age'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$city=$_POST['city'];
$province=$_POST['province'];
$status=$_POST['status'];
$isolation=$_POST['isolation_id'];
$quarantine=$_POST['quarantine_id'];
$quary="insert into patients(patient_id,patient_name,patient_age,patient_phone
,patient_email,patient_city,patient_province,patient_status,isolation_ward_id,quarantine_ward_id) Values ('$id','$fname','$age','$phone','$email'
,'$city','$province','$status','$isolation','$quarantine')";
$result=mysqli_query($con,$quary);
if($result)
{
echo"<script>alert('Data saved Successfully')</script>";
echo"<script>window.open('addpatients.php','_self')</script>";
}
}
function get_patient_details ()
{
global $con;
$quary="select *from patients";
$result=mysqli_query($con,$quary);
while($row=mysqli_fetch_array($result))
{
$id=$row['patient_id'];
$fname=$row['patient_name'];
$age=$row['patient_age'];
$phone=$row['patient_phone'];
$email=$row['patient_email'];
$city=$row['patient_city'];
$status=$row['patient_status'];
$ids='100011';
echo"
<tr>
<td>$id</td>
<td>$fname</td>
<td>$age</td>
<td>$phone</td>
<td>$email</td>
<td>$city</td>
<td>$status</td>
<td><a href='updatepatient.php?id=$row[patient_id]'>Update</a></td>
<td><a href='delpatientfunc.php?del=$row[patient_id]'>Delete</a></td>
</tr>";
}
}
function get_patient_count ()
{
global $con;
$quary="SELECT count(patient_id) AS total FROM patients";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
function get_quaratine_count ()
{
global $con;
$quary="SELECT count(quarantine_ward_id) AS total FROM quarantine_ward";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
function get_isolation_count ()
{
global $con;
$quary="SELECT count(isolation_ward_id) AS total FROM isolation_ward";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
function get_max_patient_city ()
{
global $con;
$quary="SELECT patient_city AS city FROM patients
where patient_id in
(SELECT max(patient_id)from patients)
group by patient_city";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$c=$values['city'];
echo " ".$c;
}
function get_min_patient_city ()
{
global $con;
$quary="SELECT patient_city AS city FROM patients
where patient_id in
(SELECT min(patient_id)from patients)
group by patient_city";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$c=$values['city'];
echo " ".$c;
}
function get_avg_patient_age ()
{
global $con;
$quary="SELECT Avg(patient_age) AS age FROM patients";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$c=$values['age'];
echo " ". (int)$c;
}
function get_max_patient_age ()
{
global $con;
$quary="SELECT max(patient_age) AS age FROM patients";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$c=$values['age'];
echo " ".$c;
}
function get_min_patient_age ()
{
global $con;
$quary="SELECT min(patient_age) AS age FROM patients";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$c=$values['age'];
echo " ".$c;
}
// for patients graph quaries !!!Start
function isolate_count ()
{
global $con;
$quary="SELECT count(patient_id) AS total FROM patients where patient_status='Isolate'";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
function quarantine_count ()
{
global $con;
$quary="SELECT count(patient_id) AS total FROM patients where patient_status='Qurantine'";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
function recovered_count ()
{
global $con;
$quary="SELECT count(patient_id) AS total FROM patients where patient_status='Recovered'";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
function death_count ()
{
global $con;
$quary="SELECT count(patient_id) AS total FROM patients where patient_status='Death'";
$result=mysqli_query($con,$quary);
$values=mysqli_fetch_assoc($result);
$num_rows=$values['total'];
echo $num_rows;
}
?>