<?php 
include("connectSQL_Component.php");    
    $revitVersion = [];
    $user_name = $_GET["userName"];
    $id = [];
    $path = [];
    $sql = "SELECT * FROM [BIMComponents].[dbo].[Favorite_Table] Where [user_name] = '". $user_name ."';";
    $fetchResult = sqlsrv_query($conn, $sql);
    while($row = sqlsrv_fetch_array($fetchResult,SQLSRV_FETCH_ASSOC)){
        array_push($revitVersion,$row['revitVersion']);
        array_push($id,$row['id']);
        array_push($path,$row['favorite']);
    }
    $year = array_unique($revitVersion);
    sort($year);    
    $array = [];
    $array["year"] = $year;
    $array["revitVersion"] = $revitVersion;
    $array["path"] = $path;
    $array["id"] = $id;

    echo json_encode($array);   
sqlsrv_close( $conn );
?>