<?php
    
    $json = file_get_contents('php://input');   
    $obj = json_decode($json);
    $conn = mysqli_connect("directoriofitness.com.mx","direct18","L4LL4v3M@3str@",$obj->bd);
    mysqli_set_charset($conn, 'utf8');
    // Returns a Json
    //header('Content-Type: application/json');
    $array; 
    
    $query = "SELECT socios.idSocio as 'id_cliente', CONCAT(socios.Nombre, ' ', socios.Apellidos) as 'nombre', 
        TIMESTAMPDIFF(YEAR,DATE(socios.FechaNacimiento),CURDATE()) as 'edad', fecha_registro as 'registro', peso_cliente as 'peso', 
        talla_cliente as 'talla', objetivo as 'obj', brazo as 'v1', brazo_contraido as 'v2', cintura as 'v3', 
        cintura_ombligo as 'v4', cintura_baja as 'v5', cadera as 'v6', pecho as 'v7', muslo as 'v8', pantorrilla as 'v9', 
        biceps as 'v10', triceps as 'v11', espalda as 'v12', espalda_baja as 'v13', oblicuos as 'v14', oblicuos_atras as 'v15', 
        abdomen as 'v16', abdomen_alto as 'v17', abdomen_bajo as 'v18', muslo_pliegue as 'v19', pantorrilla_pliegue as 'v20', 
        sumatoria as 'v21', biestiloideo as 'v22', bicondileo as 'v23', muñeca as 'v24', rodilla as 'v25', porcentaje_grasa as 'v26', 
        kg_grasa as 'v27', kg_musculo as 'v28', masa_osea as 'v29', masa_residual as 'v30', masa_limpia as 'v31', sucursal.NombreSucursal 
        as 'sucursal' FROM progresion_socios, socios, sucursal WHERE progresion_socios.socio_idsocio = socios.idSocio AND progresion_socios.socio_idsocio = '$obj->id_cliente' 
        ORDER BY progresion_socios.id_registro_progresion ASC";
        
    
    $result = mysqli_query($conn, $query);
      
    $n = mysqli_num_rows($result);
    if($n > 0){
        while($row = mysqli_fetch_array($result)){
            $array[] = $row;
        }
        
        echo json_encode($array);
    }else{
        echo 'nada';
    }
    
    mysqli_close($conn);
?>