='".$start_date."' "; $qry_date.=" and checkup_date >=str_to_date('".$start_date."','%d-%m-%Y') "; } if(isset($end_date) && $end_date!=''){ //$qry_date.=" and checkup_date <='".$end_date."' "; $qry_date.=" and checkup_date <=str_to_date('".$end_date."','%d-%m-%Y') "; } $i=0; $record =array(); $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>=0 and YEAR(CURDATE())-year(doj)<2 ".$qry_bu; //echo $query1; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='18-25'; $record[$i]['total'] =$row['total']; } } $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>=0 and YEAR(CURDATE())-year(doj)<2 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } //echo $query; $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>=2 and YEAR(CURDATE())-year(doj)<5 ".$qry_bu; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='26-30'; $record[$i]['total'] =$row['total']; } } $query1="select id FROM employee where YEAR(CURDATE())-year(doj)>=2 and YEAR(CURDATE())-year(doj)<5 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } //$query1="select id FROM employee where YEAR(CURDATE())-year(dob)>=31 and YEAR(CURDATE())-year(dob)<=40 ".$qry_bu; $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>5 and YEAR(CURDATE())-year(doj)<=10 ".$qry_bu; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='26-30'; $record[$i]['total'] =$row['total']; } } $query1="select id FROM employee where YEAR(CURDATE())-year(doj)>5 and YEAR(CURDATE())-year(doj)<=10 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>10 and YEAR(CURDATE())-year(doj)<=15 ".$qry_bu; //echo $query; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='41-50'; $record[$i]['total'] =$row['total']; } } $query1="select id FROM employee where YEAR(CURDATE())-year(doj)>10 and YEAR(CURDATE())-year(doj)<=15 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>15 and YEAR(CURDATE())-year(doj)<=20 ".$qry_bu; //echo $query; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='>50'; $record[$i]['total'] =$row['total']; } } $query1="select id FROM employee where YEAR(CURDATE())-year(doj)>15 and YEAR(CURDATE())-year(doj)<=20 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>20 and YEAR(CURDATE())-year(doj)<=25 ".$qry_bu; //echo $query; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='>50'; $record[$i]['total'] =$row['total']; } } $query1="select id FROM employee where YEAR(CURDATE())-year(doj)>20 and YEAR(CURDATE())-year(doj)<=25 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } $query1="select ifnull(count(*),0) as total FROM employee where YEAR(CURDATE())-year(doj)>25 ".$qry_bu; //echo $query; if (!$result = @mysqli_query($conn,$query1)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['key'] ='>50'; $record[$i]['total'] =$row['total']; } } $query1="select id FROM employee where YEAR(CURDATE())-year(doj)>25 ".$qry_bu; $query="SELECT ifnull(count(*),0) as total from emp_level_hyg_check where emp_id in ($query1) $qry_date"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $record[$i]['abnormal_total'] =$row['total']; $i++; } } echo json_encode($record); ?>