注意:未定义的索引| PHP MySQL

I'm trying to retrieve specific table data from MySQL and using PHP to display the information. Should be simple enough to retrieve the data and print it but I get undefined index only when retrieving the data and trying to display.

I'm retrieving the information and displaying the information in a profile page according to the username in the header.

if(isset($_GET['username']))
{
    $username           = $_GET['username'];
    $profile_uid        = $Wall->useriD($username);
    $profile_details    = $Wall->userDetails($profile_uid);
    $friend_count       = $profile_details['friendcount']; //issue here
} else {
    header('Location:404.php');
}

I get the undefined index on the $friend_count = $profile_details['friendcount']; but I'm not sure why, I believed everything checked correctly but apparently not. Here is how I'm fetching the information.

public function useriD($username)
{
    $sth = $this->db->prepare("SELECT uiD FROM users WHERE username = :username AND status='1'");
    $sth->execute(array(':username' => $username));

    if($sth->rowCount() == 1)
    {
        $row = $sth->fetch();
        return $row['uiD'];
    } else {
        return false;
    }
}

public function userDetails($uiD)
{
    $sth = $this->db->prepare("SELECT * FROM users WHERE uiD = :uiD AND status='1'");
    $sth->execute(array(':uiD' => $uiD));

    $data = $sth->fetchAll();
    return $data;
}

The issue is when I try to display the information such , I've been at it for a few hours and I'm stuck. Any leads would be great.

In your userDetails function, fix the last statement:

return $data[0];

(You might also want to precheck whether $data[0] exists, and if it does not, return NULL, FALSE or throw an exception.)

Since you're only interested in one row, use fetch() instead of fetchAll():

$data = $sth->fetch();