0) { while ($row_stock_item = mysqli_fetch_assoc($result_stock_item)) { //extract($row); $data[] = $row_stock_item; } } else { $data['status'] = 200; $data['message'] = "Data not found!"; } if (!empty($_POST['p_id'])) { $sql_opd = "SELECT distinct(i.item_id),trim(concat(ifnull(i.item_code,''),' ',i.item_name)) item_name FROM treatment t left join tbl_items i on t.item_id=i.item_id WHERE t.appointment_id in (select appointment_id from employee_appointment where emp_id='" . $_POST['p_id'] . "' and ohc_type_id='" . $_SESSION['current_ohcttype'] . "' )"; error_log("get item::" . $sql_opd); if (!$result_opd = @mysqli_query($conn, $sql_opd)) { die(mysqli_error($conn)); } if (@mysqli_num_rows($result_opd) > 0) { while ($row_opd = @mysqli_fetch_assoc($result_opd)) { array_push($data, $row_opd); } } } error_log(print_r($data, true)); echo json_encode($data);