='".$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; $record =array(); // $query="select count(a.id) as total, f.dept_name from covid_monitoring a left join patient_master b on a.emp_id = b.id left join covid_patient_staying c on a.staying_id = c.id left join covid_test_result_master d on a.covid_test_result_id = d.id left join covid_contact_type_master e on a.covid_contact_id = e.id left join department f on b.dept_id = f.dept_id group BY f.dept_name "; // //echo $query; // if (!$result = @mysqli_query($conn,$query)) { // exit(mysqli_error($conn)); // } // if(mysqli_num_rows($result) > 0) { // while ($row = @mysqli_fetch_assoc($result)) { // $record[$i]['bmi_total']=$row['total']; // $record[$i]['dept_name']=$row['dept_name']; // $i++; // } // } $query="select count(a.id) as total, f.dept_name from covid_monitoring a left join patient_master b on a.emp_id = b.id left join department f on b.dept_id = f.dept_id where (a.staying_id = '1' or a.staying_id='2') $qry_bu group by f.dept_name "; // echo $query; error_log("query ".$query); if (!$result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result) > 0) { while ($row = @mysqli_fetch_assoc($result)) { $record[$i]['bmi_total']=$row['total']; $record[$i]['dept_name']=$row['dept_name']; $i++; } } $new_query="SELECT count(*) as total_active from covid_monitoring where id in (select a.id from covid_monitoring a left join patient_master b on a.emp_id = b.id left join department f on b.dept_id = f.dept_id where (a.staying_id='1' or a.staying_id='2') $qry_bu group by f.dept_name )"; //echo $query; error_log('new query: '.$new_query); if (!$new_result = @mysqli_query($conn,$new_query)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($new_result) > 0) { if ($row = @mysqli_fetch_assoc($new_result)) { for ($i=0; $i < count($record); $i++) { // code... $record[$i]['total_active']=$row['total_active']; } } } echo json_encode($record); ?>