<?php
include('dbconnect.php');

$id = $_POST['id'];
$query = mysqli_query($conn, "SELECT * FROM tbl_invite_user WHERE id = '$id'");
$row = mysqli_fetch_assoc($query);

// You can also get project data here if needed
$project_ids = [];

$proj_query = mysqli_query($conn, "SELECT tbl_lead_user_access_projects_project_id FROM tbl_lead_user_access_projects WHERE tbl_lead_user_access_projects_user_id = '".$id."'");
// $proj_query = "SELECT tbl_lead_user_access_projects_project_id FROM tbl_lead_user_access_projects WHERE tbl_lead_user_access_projects_user_id = ?";
// $query = "SELECT tbl_lead_user_access_projects_project_id as project_id 
//               FROM tbl_lead_user_access_projects 
//               WHERE tbl_lead_user_access_projects_user_id = ?";
              
    // $stmt = $conn->prepare($proj_query);
    // $stmt->bind_param("i", $id);
    // $stmt->execute();
    // $result = $stmt->get_result();
    
    // $projects = [];
    // while($row1 = $result->fetch_assoc()) {
    //     $projects[] = $row1['tbl_lead_user_access_projects_project_id'];
    // }
    
   // $projects = [];
while($proj = mysqli_fetch_assoc($proj_query)) {
    $project_ids[] = $proj['tbl_lead_user_access_projects_project_id'];
}

$row['project_ids'] = $project_ids;

echo json_encode($row);
