=str_to_date('".$start_date."','%d-%m-%Y') "; } if(isset($end_date) && $end_date!=''){ $qry_filter.=" and date(doj) <=str_to_date('".$end_date."','%d-%m-%Y') "; } if(isset($month) && $month!=''){ $qry_filter.=" and month(doj) in (".$month.")"; } $data = array(); if(isset($year) && $year!='' && sizeof($year1)>1){ for($j=0; $j50'] query:".$query5); $query="select count(*) as total_count from patient_master where status = 'Active' $qry_date $qry_filter"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } $row_count = mysqli_fetch_assoc($result); error_log("count query:".$query); if(mysqli_num_rows($result1) > 0) { if ($row1 = mysqli_fetch_assoc($result1)) { $per_for_18_to_25 = ($row1['total']/$row_count['total_count'])*100; $data['18-25'][$year1[$j]]['total'] = round($per_for_18_to_25,2); } } if(mysqli_num_rows($result2) > 0) { if ($row2 = mysqli_fetch_assoc($result2)) { $per_for_26_to_30 = ($row2['total']/$row_count['total_count'])*100; $data['26-30'][$year1[$j]]['total'] = round($per_for_26_to_30,2); } } if(mysqli_num_rows($result3) > 0) { if ($row3 = mysqli_fetch_assoc($result3)) { $per_for_31_to_40 = ($row3['total']/$row_count['total_count'])*100; $data['31-40'][$year1[$j]]['total'] = round($per_for_31_to_40,2); } } if(mysqli_num_rows($result4) > 0) { if ($row4 = mysqli_fetch_assoc($result4)) { $per_for_41_to_50 = ($row4['total']/$row_count['total_count'])*100; $data['41-50'][$year1[$j]]['total'] = round($per_for_41_to_50,2); } } if(mysqli_num_rows($result5) > 0) { if ($row5 = mysqli_fetch_assoc($result5)) { $per_greater_than_50 = ($row5['total']/$row_count['total_count'])*100; $data['>50'][$year1[$j]]['total'] = round($per_greater_than_50,2); } } } } else{ if(isset($year2) && $year2!=''){ $qry_filter.=" and year(doj) <='".$year2."'"; } $query="SELECT count(*) as total FROM patient_master where YEAR(CURDATE())-year(dob)>=18 and YEAR(CURDATE())-year(dob)<=25 and status = 'Active' $qry_filter"; //echo $query.$qry_bu; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $data['age_18_25'] = $row; } } error_log("['age_18_25'] query:".$query); $query="SELECT count(*) as total FROM patient_master where YEAR(CURDATE())-year(dob)>=26 and YEAR(CURDATE())-year(dob)<=30 and status = 'Active' $qry_filter"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $data['age_26_30'] = $row; } } error_log("['age_26_30'] query:".$query); $query="SELECT count(*) as total FROM patient_master where YEAR(CURDATE())-year(dob)>=31 and YEAR(CURDATE())-year(dob)<=40 and status = 'Active' $qry_filter"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $data['age_31_40'] = $row; } } error_log("['age_31_40'] query:".$query); $query="SELECT count(*) as total FROM patient_master where YEAR(CURDATE())-year(dob)>=41 and YEAR(CURDATE())-year(dob)<=50 and status = 'Active' $qry_filter"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $data['age_41_50'] = $row; } } error_log("['age_41_50'] query:".$query); $query="SELECT count(*) as total FROM patient_master where YEAR(CURDATE())-year(dob)>50 and status = 'Active' $qry_filter"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $data['age_more50'] = $row; } } error_log("['age_more50'] query:".$query); $query="SELECT count(*) as total FROM patient_master where status = 'Active' $qry_filter"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $data['total_count'] = $row; } } error_log("count query:".$query); } echo json_encode($data); ?>