<?php
session_start();
include('../includes/config.php');

$user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0;

if ($user_id > 0) {
    $sql = "SELECT fund_balance, available_balance, total_profit FROM users WHERE id = $user_id";
    $result = mysqli_query($conn, $sql);
    
    if ($row = mysqli_fetch_assoc($result)) {
        echo json_encode(array(
            'success' => true,
            'fund_balance' => number_format($row['fund_balance'], 2),
            'available_balance' => number_format($row['available_balance'], 2),
            'total_profit' => number_format($row['total_profit'], 2)
        ));
    } else {
        echo json_encode(array('success' => false));
    }
} else {
    echo json_encode(array('success' => false));
}
?>