为什么不用ASP
那样会简单得多了!

解决方案 »

  1.   

    定时刷新页面,同时 
    $sql = "Update TableName set last_login='$today' where account='$account'";
    mysql_query($sql);
    其中
    TableName是登陆数据库表
    $today = date("Y-m-d H:i:s");
    $account 是用户帐号
      

  2.   

    //----在用户登陆页面,定时刷新页面------
    <?
    $today = date("Y-m-d H:i:s");
    $sql = "Update TableName set last_login='$today' where account='$account'";
    mysql_query($sql);
    //--其中--
    //--TableName是登陆数据库表--
    //--$account 是用户帐号--
    ?><?
    //---------检查在线用户--------
    $sql = "Select * from TableName order by last_login";
    $result = mysql_query($sql);
    while($dbRow = mysql_fetch_object($result))
    {
    $theDateTime = $dbRow->last_login;
    $hour = intval(substr($theDateTime,11,2));
    $minute = intval(substr($theDateTime,14,2));
    $second = intval(substr($theDateTime,17,2));
    $month = intval(substr($theDateTime,5,2));
    $day = intval(substr($theDateTime,8,2));
    $year = intval(substr($theDateTime,0,4));
    $lasttime = mktime($hour, $minute, $second, $month, $day, $year);
    $nowtime = mktime();
    $totaltime= $nowtime-$lasttime;
    //----上次登陆到现在的时间差------
    //----如果这个数值在一定范围以内则认为该用户在线,例如120秒
    if($totaltime<120)echo "$account 在线<br>";
    else break;
    }
    ?>
      

  3.   

    错了,把else break;去掉或把
    $sql = "Select * from TableName order by last_login";
    改为
    $sql = "Select * from TableName order by last_login desc";
      

  4.   

    在你的用户表中设置一个用户是否登录的字段,然后
    select username from users where islogon=1
    或者用一个文件保存当前登录用户的名单
    $logusers = file(登录用户名单文件);
    更好的方法是同时记录用户的登录时间,然后采用某种机制,让用户在指定的时间内再次访问你的网站,如果超过了规定的时间仍然没有访问则视为用户掉线。将从在线名单中剔除。
      

  5.   

    http://www.langwan.com/article.php?Action=ArticleList&SID=PHP文章_实例精解&RowCount=1&AID=1041713488