='".$start_date."' "; // $qry_date.=" and medical_entry_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 medical_entry_date <=str_to_date('".$end_date."','%d-%m-%Y') "; // } // $i=0; // $weight =array(1,2,3,4,5,-1,-2,-3,-4,-5,0); $increase_weight_upto1=0; $increase_weight_upto1_to_2=0; $increase_weight_upto2_to_3=0; $increase_weight_upto3_to_4=0; $increase_weight_upto4_to_5=0; $increase_weight_upto5plus=0; $decrease_weight_upto1=0; $decrease_weight_upto1_to_2=0; $decrease_weight_upto2_to_3=0; $decrease_weight_upto3_to_4=0; $decrease_weight_upto4_to_5=0; $decrease_weight_upto5plus=0; $weight_no_change=0; $query = "select md1.weight as wt1, md2.weight as wt2,(md1.patient_id) , (md1.weight-md2.weight )wt_diff from (select patient_id, weight,bmi from medical_examination where year(medical_entry_date) like '2021') md1,(select patient_id, weight,bmi from medical_examination where year(medical_entry_date) like '2020') md2 where md1.patient_id=md2.patient_id"; if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } while($row = mysqli_fetch_array($result)){ if($row['wt_diff']>0 && $row['wt_diff']<=1){ $increase_weight_upto1++; } if($row['wt_diff']>1 && $row['wt_diff']<=2){ $increase_weight_upto1_to_2++; } if($row['wt_diff']>2 && $row['wt_diff']<=3){ $increase_weight_upto2_to_3++; } if($row['wt_diff']>3 && $row['wt_diff']<=4){ $increase_weight_upto3_to_4++; } if($row['wt_diff']>4 && $row['wt_diff']<=5){ $increase_weight_upto4_to_5++; } if($row['wt_diff']>=5 ){ $increase_weight_upto5plus++; } if($row['wt_diff']< 0 && $row['wt_diff']>= -1){ $decrease_weight_upto1++; } if($row['wt_diff'] < -1 && $row['wt_diff'] >= -2){ $decrease_weight_upto1_to_2++; } if($row['wt_diff'] < -2 && $row['wt_diff'] >= -3){ $decrease_weight_upto2_to_3++; } if($row['wt_diff'] < -3 && $row['wt_diff'] >= -4){ $decrease_weight_upto3_to_4++; } if($row['wt_diff'] < -4 && $row['wt_diff'] >= -5){ $decrease_weight_upto4_to_5++; } if($row['wt_diff'] <= -5 ){ $decrease_weight_upto5plus++; } if($row['wt_diff'] == 0 ){ $weight_no_change++; } } // $data['increase_weight_upto1'] = $increase_weight_upto1; // $data['increase_weight_upto1_to_2'] = $increase_weight_upto1_to_2; // $data['increase_weight_upto2_to_3'] = $increase_weight_upto2_to_3; // $data['increase_weight_upto3_to_4'] = $increase_weight_upto3_to_4; // $data['increase_weight_upto4_to_5'] = $increase_weight_upto4_to_5; // $data['increase_weight_upto5plus'] = $increase_weight_upto5plus; // $data['decrease_weight_upto1'] = $decrease_weight_upto1; // $data['decrease_weight_upto1_to_2'] = $decrease_weight_upto1_to_2; // $data['decrease_weight_upto2_to_3'] = $decrease_weight_upto2_to_3; // $data['decrease_weight_upto3_to_4'] = $decrease_weight_upto3_to_4; // $data['decrease_weight_upto4_to_5'] = $decrease_weight_upto4_to_5; // $data['weight_no_change'] = $weight_no_change; $array1 = array(1,$increase_weight_upto1,1*$increase_weight_upto1); $data[]=$array1; $array2 = array(2,$increase_weight_upto1_to_2,2*$increase_weight_upto1_to_2); $data[]=$array2; $array3 = array(3,$increase_weight_upto2_to_3,3*$increase_weight_upto2_to_3); $data[]=$array3; $array4 = array(4,$increase_weight_upto3_to_4,4*$increase_weight_upto3_to_4); $data[]=$array4; // $array1 = array(1,$increase_weight_upto4_to_5,1*$increase_weight_upto1); // $data[]=$array1; $array5 = array(5,$increase_weight_upto5plus,5*$increase_weight_upto5plus); $data[]=$array5; $array6 = array(-1,$decrease_weight_upto1,-1*$decrease_weight_upto1); $data[]=$array6; $array7 = array(-2,$decrease_weight_upto1_to_2,-2*$decrease_weight_upto1_to_2); $data[]=$array7; $array8 = array(-3,$decrease_weight_upto2_to_3,-3*$decrease_weight_upto2_to_3); $data[]=$array8; $array9 = array(-4,$decrease_weight_upto3_to_4,-4*$decrease_weight_upto3_to_4); $data[]=$array9; $array10 = array(-5,$decrease_weight_upto4_to_5,-5*$decrease_weight_upto4_to_5); $data[]=$array10; $array11 = array(0,$weight_no_change,0*$weight_no_change); $data[]=$array11; echo json_encode($data); ?>