UserRole(); $username = $fgmembersite->UserName(); if ($userrole == 'Admin' ||$userrole == "Super"){ $where = 'where username <> "'.$username.'"'; } else { $where = " where role in('Admin','Super')";} $query='SELECT distinct(username),role FROM loggeduser '.$where.' group by role'; $result = mysql_query ($query); $role=""; if (mysql_num_rows($result) >0){ while($nt=mysql_fetch_array($result)){ if ($role != $nt['role']){$role = $nt['role'];echo ''.$role.'';} echo ''.$nt['username'].''; } } else echo 'No Users'; ?>