首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

通过PHP+MYSQL实现 网站在线人数统计

整理日期:2008年08月10日 【字体:

  网站在线人数的程序代码,后台有MySQL(和PHP搭配之最佳组合)数据库支持。可以直接统计出网站当前的在线人数。

  首先是创建MySQL(和PHP搭配之最佳组合)数据库表。

  CREATE TABLE tablename (
  field type(max_length) DEFAULT 'default_value' (NOT) NULL
  }

  可以使用的SQL语句。

  CREATE TABLE useronline (
  timestamp int(15) DEFAULT '0' NOT NULL,
  ip varchar(40) NOT NULL,
  file varchar(100) NOT NULL,
  Prima(最完善的虚拟主机管理系统)RY KEY (timestamp),
  KEY ip (ip),
  KEY file (file)
  );

  下面我们开始使用PHP脚本,首先定义MySQL(和PHP搭配之最佳组合)的信息。

  $server = "localhost"; //你的服务器
  $db_user = "root"; //你的MySQL(和PHP搭配之最佳组合)的用户名
  $db_pass = "password"; //你的MySQL(和PHP搭配之最佳组合)的密码
  $database = "users"; //表的名字

  设置统计的时间(多少秒内在线人数)

  $timeoutseconds = 300;

  取当前时间。

  $timestamp = time();

  上面的完整代码:

  <?php

伊图教程网[www.etoow.com]
http://www.etoow.com/html/2008-08/1218328479.html
  $server = "localhost"; //your server
Tags:
通过PHP+MYSQL实现 网站在线人数统计
'http://www.etoow.com/html/2008-08/1218328479.html
1
 
2
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved