How to show the selected user is admin in php
<p>In one query i am getting all the user details in the user table.</p>

<pre><code>$userDetails =  $dbUser -&gt;getAllUsers();
</code></pre>

<p>In second query i am getting the user details which are there in the selected group.</p>

<pre><code>$groupMemberDetails = $dbGroupMembers -&gt;getAllGroupMembers($groupId);
</code></pre>

<p>But if the user is in selected group i have to show them as selected remaining user as unselected and also if he is owner show it as admin append to his name. </p>

<p>I have done following code but i am not getting properly.</p>

<p>Please correct me.</p>

<pre><code>foreach ( $userDetails as $user ) {

    $userId = $user['user_id'];
    $userFirstName = $user['first_name'];
    $userName = '';

    $selected = "";
    foreach ( $groupMemberDetails as $groupMemberDetail ) {
        $groupMemberId = $groupMemberDetail['user_id'];
        if($groupMemberId == $userId) {
            $selected = "selected";
        }
        $isAdmin = $groupMemberDetail['is_owner'];
        if($isAdmin) {
            $userName = $userFirstName . "(admin)";
        } else {
            $userName = $userFirstName;
        }

    }
    echo '&lt;option value="'.$userId.'" '.$selected.'&gt;'. $userName . '&lt;/option&gt;';
}
</code></pre>
