0) { while ($row = @mysqli_fetch_array($result)) { array_push($medical_date, $row[1]); $blood_sugar_rbs['rbs'][$row[1]] = $row[0]; } } $query = "SELECT blood_sugar_fbs as fbs, date(appointment_date) as dat FROM employee_appointment where emp_id='$id'and blood_sugar_fbs != '' or blood_sugar_fbs != 0 UNION SELECT cf.checkup_form_value as fbs ,date(c.checkup_date) as dat from checkup_form c left join checkup_form_key_value cf on c.checkup_id=cf.checkup_form_id left join checkup_parameter cp on cp.`column_name` = cf.checkup_form_key where c.emp_id='$id' and cp.key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='fbs') order by dat desc limit 25"; error_log("fbs query " . $query); $result = @mysqli_query($conn, $query); if (mysqli_num_rows($result) > 0) { while ($row = @mysqli_fetch_array($result)) { array_push($medical_date, $row[1]); $blood_sugar_fbs['fbs'][$row[1]] = $row[0]; } } $query = "SELECT blood_sugar_ppbs as ppbs, date(appointment_date) as dat FROM employee_appointment where emp_id='$id'and blood_sugar_ppbs != '' or blood_sugar_ppbs != 0 UNION SELECT cf.checkup_form_value as ppbs ,date(c.checkup_date) as dat from checkup_form c left join checkup_form_key_value cf on c.checkup_id=cf.checkup_form_id left join checkup_parameter cp on cp.`column_name` = cf.checkup_form_key where c.emp_id='$id' and cp.key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='ppbs') order by dat desc limit 25"; error_log("ppbs query " . $query); $result = @mysqli_query($conn, $query); if (mysqli_num_rows($result) > 0) { while ($row = @mysqli_fetch_array($result)) { array_push($medical_date, $row[1]); $blood_sugar_ppbs['ppbs'][$row[1]] = $row[0]; } } $medical_date = array_values(array_unique($medical_date)); error_log("sugar chart date array " . print_r($medical_date, true)); for ($i = 0; $i < sizeof($medical_date); $i++) { error_log("inside loop value" . $blood_sugar_rbs['rbs'][$medical_date[$i]]); error_log("inside loop value" . $blood_sugar_fbs['fbs'][$medical_date[$i]]); error_log("inside loop value" . $blood_sugar_ppbs['ppbs'][$medical_date[$i]]); if ($blood_sugar_rbs['rbs'][$medical_date[$i]] == '') { array_push($rbs_new, 0); } else { array_push($rbs_new, $blood_sugar_rbs['rbs'][$medical_date[$i]]); } if ($blood_sugar_fbs['fbs'][$medical_date[$i]] == '') { array_push($fbs_new, 0); } else { array_push($fbs_new, $blood_sugar_fbs['fbs'][$medical_date[$i]]); } if ($blood_sugar_ppbs['ppbs'][$medical_date[$i]] == '') { array_push($ppbs_new, 0); } else { array_push($ppbs_new, $blood_sugar_ppbs['ppbs'][$medical_date[$i]]); } } error_log("final height " . print_r($rbs_new, true)); error_log("final weight " . print_r($fbs_new, true)); error_log("final bmi " . print_r($ppbs_new, true)); ?>