-
Notifications
You must be signed in to change notification settings - Fork 0
/
pra.php
46 lines (38 loc) · 855 Bytes
/
pra.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
<?php
header('Content-Type: application/json');
$db=mysqli_connect('localhost','root','','att');
$reg="17BCE1328";
$sql="SELECT subid from students where regno='$reg' ORDER BY subid;";
$data=array();
$dataf=array();
$res=mysqli_query($db,$sql);
foreach($res as $row)
{
$k=0; //k is used here for storing the no of days a guy is present
$subid=$row['subid'];
$data['subid']="$subid";
$sql2="SELECT atten FROM atte where regno='$reg'and subid='$subid';";
$r=mysqli_query($db,$sql2);
$tot=mysqli_num_rows($r);
foreach($r as $ro)
{
$a=$ro['atten'];
if ($a=="Present")
{
$k=$k+1;
}
}
if($tot==0)
{
$fra=0;
}
else
{
$fra= $k/$tot;
}
$fra=$fra*100; //fra is the final attendance percentage
$data['at']=$fra;
$dataf[]=$data;
}
echo json_encode($dataf); //encoding json array with the data which we found
?>