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

if (isset($_POST['lead_id'])) {
    $leadId = $_POST['lead_id'];

    // Prepare the SQL statement to prevent SQL injection
    $stmt = $conn->prepare("SELECT tbl_lead_user_prj_id, tbl_lead_user_projects_name FROM tbl_lead_user_projects WHERE tbl_lead_user_id = ?");
    $stmt->bind_param("i", $leadId);
    $stmt->execute();
    $result = $stmt->get_result();

    $projects = array();
    while ($row = $result->fetch_assoc()) {
        $projects[] = $row;
    }

    echo json_encode($projects);
}
?>