有没有很好方法,获得在线登陆用户名单 为什么不用ASP那样会简单得多了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 定时刷新页面,同时 $sql = "Update TableName set last_login='$today' where account='$account'";mysql_query($sql);其中TableName是登陆数据库表$today = date("Y-m-d H:i:s");$account 是用户帐号 //----在用户登陆页面,定时刷新页面------<?$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;}?> 错了,把else break;去掉或把$sql = "Select * from TableName order by last_login";改为$sql = "Select * from TableName order by last_login desc"; 在你的用户表中设置一个用户是否登录的字段,然后select username from users where islogon=1或者用一个文件保存当前登录用户的名单$logusers = file(登录用户名单文件);更好的方法是同时记录用户的登录时间,然后采用某种机制,让用户在指定的时间内再次访问你的网站,如果超过了规定的时间仍然没有访问则视为用户掉线。将从在线名单中剔除。 http://www.langwan.com/article.php?Action=ArticleList&SID=PHP文章_实例精解&RowCount=1&AID=1041713488 您的 PHP 似乎没有安装运行 WordPress 所必需的 MySQL 扩展。 为什么fetch_array() 得不到数据? 调用一个.net soap 判断一个值属于某个数组,怎么写呢? 关于正则表达式, 表单的问题 如何设置apache让其支持二级域名 一个JS问题 讨论一下,eregi和strpos php升级到4.20后遇到的问题,急!急!急!!! 如何做视频新闻 有人用PHP编wap的程序吗,图片和铃声文件下载到手机如何实现啊?
$sql = "Update TableName set last_login='$today' where account='$account'";
mysql_query($sql);
其中
TableName是登陆数据库表
$today = date("Y-m-d H:i:s");
$account 是用户帐号
<?
$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;
}
?>
$sql = "Select * from TableName order by last_login";
改为
$sql = "Select * from TableName order by last_login desc";
select username from users where islogon=1
或者用一个文件保存当前登录用户的名单
$logusers = file(登录用户名单文件);
更好的方法是同时记录用户的登录时间,然后采用某种机制,让用户在指定的时间内再次访问你的网站,如果超过了规定的时间仍然没有访问则视为用户掉线。将从在线名单中剔除。