View Single Post
Sorting online users
Old
  (#1 (permalink))
aramis
Junior Member
 
Status: Offline
Posts: 10
Join Date: Sep 2004
Sorting online users - 10-04-2004, 03:19 PM

Hi.

I have the user_info block and modified it so that it displays a small U.S. Army rank graphic next to the user that is currently online . The problem I now have is that I want to sort the users according to rank i.e. when a Sergeant comes on he should be displyed above the Privates. Another problem is if two Sergeants are online or two or three Privates I need to sort not only by the rank but also by the lastname. Any suggestions on how I might be able to do this? Both the username and rankimage are in the same table. I have tried ORDER BY but no change.

Here is the part of the script that I have now, you can view the block at www.32bat.com
Code:
$who_online_now = "";
$i = "1";

while ( $session = sql_fetch_array( $result2, $dbi ) )
{
   if ( isset($session["guest"]) and $session["guest"] == 0 )
   {
            $FlagResult = sql_query( "select user_ranksmall from ".$prefix."_users where username = '$session[uname]'", $dbi );
      $FlagInfo =   sql_fetch_array( $FlagResult, $dbi );
      
   
      $FlagPath = "/nuke/images/rankssmall/";
     if ( $FlagInfo[user_ranksmall] == "0" )
   {
          $FlagPathFile = "/nuke/images/flags/guest";}
else
      {

$FlagPathFile = $FlagPath.$FlagInfo[user_ranksmall];
      }

           $resultuser_id = sql_query( "SELECT user_id FROM ".$prefix."_users where username='$session[uname]'", $dbi );
      list( $user_id ) = sql_fetch_row( $resultuser_id, $dbi );
     
      $who_online_now .= "<img src=\"$FlagPathFile.gif\" ><A HREF=\"modules.php?name=Private_Messages&file=index&mode=post&&u=$user_id\">$session[uname]</a>
\n";
      $who_online_now .= ( $i != $member_online_num ? "  " : "" );
      $i++;
   }
}
[/code]
   
Reply With Quote