<?php

header('Content-type: application/json; charset=UTF-8');

$fk_id_func_respon = $_GET['fk_id_func_respon'];

if(!empty($fk_id_func_respon)){
    $fk_id_func_respon = $fk_id_func_respon;
}else{
    $fk_id_func_respon = 0;
}

include 'conexion.php';
$consulta = "SELECT `id_func_respon`,`nom_func_respon`,(SELECT COUNT(activos.id_activo) 
           FROM activos WHERE activos.fk_id_func_respon = ".$fk_id_func_respon.") AS NUM_TOTAL
             FROM funci_responsable 
             ORDER BY nom_func_respon";

$resultado = $conexion->query($consulta);

while($fila = $resultado -> fetch_array()){
    $funci_responsable[] = $fila;
}

echo json_encode($funci_responsable, JSON_UNESCAPED_UNICODE);
$resultado -> close();

?>