$array_friends = array();
    $array_friends_open = array();
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        $array_friends[] = $row;
    }
}
$members = sortArray($array_friends, "Nachname");
$output .= '<table width="100%" cellpadding="0" cellspacing="0">';
if ($profil_id == $user_id) {
    $output .= '<tr>
		<td colspan="3" class="infounderlined">Offene Freundschaftsanfragen</td>
	</tr>';
    if (empty($array_friends_open)) {
        $output .= '<tr><td colspan="3">Keine offenen Freundschaftsanfragen vorhanden</td></tr>';
    }
    foreach ($array_friends_open as $friend) {
        $output .= renderFriendOutput($friend['idFriend'], $friend['Vorname'] . " " . $friend['Nachname'], $friend['status'] == 0 ? 1 : $friend['status']);
    }
    $style = 'style="padding-top: 20px"';
}
$output .= '<tr>
		<td colspan="3" class="infounderlined" ' . (!empty($style) ? $style : '') . '>Bestehende Freundschaften</td>
	</tr>';
if (empty($array_friends)) {
    $output .= '<tr><td colspan="3">Keine Freunde vorhanden</td></tr>';
}
foreach ($array_friends as $friend) {
    $output .= renderFriendOutput($friend['idFriend'], $friend['Vorname'] . " " . $friend['Nachname'], $friend['isFriend']);
}
$output .= '</table>';
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_array($result)) {
        if ($row['Typ'] == "f") {
            $request_friends[] = $row;
        } elseif ($row['Typ'] == "g") {
            $request_groups[] = $row;
        }
    }
    $output .= '<table width="100%" cellpadding="0" cellspacing="0">';
    if (count($request_friends) > 0) {
        $output .= '<tr>
				<td colspan="3" class="infounderlined">Freundschaftsanfragen</td>
			</tr>';
        foreach ($request_friends as $anfrage) {
            $output .= renderFriendOutput($anfrage['idAnfrage'], $anfrage['Name'], 3);
        }
    }
    if (count($request_groups) > 0) {
        $output .= '<tr>
				<td colspan="3" class="infounderlined" ' . (count($request_friends) > 0 ? "style=\"padding-top: 20px\"" : "") . '">Gruppen-Einladungen</td>
			</tr>';
        foreach ($request_groups as $anfrage) {
            $output .= renderFriendOutput($anfrage['idAnfrage'], $anfrage['Name'], 3, true);
        }
    }
    $output .= '</table>';
} else {
    $output .= 'Keine offenen Anfragen vorhanden';
}
$output .= '</div>';