根据许多网友需求,特地把我站的这个模拟 OICQ 的在线聊天的东西献给大家!1 用户必须注册登陆,在数据库 userinfo 里面保存如下几个字段Name 不用问了,这是登陆用的用户名,必须唯一Password 登陆密码NickName 用户昵称,也就是显示的名字Face 存放着用户头像的编号,比如 01,代表 /images/face/01.gif 头像文件OnlineStatus 用户是否在线的标志,在用户登陆的时候设置为 1CurrentDate 用户最后访问/更新的时间,用于判断用户是否在线聊天纪录 forumtalk 的结构为CREATE TABLE forumtalk (id int(11) NOT NULL auto_increment,sender varchar(20) NOT NULL,receiver varchar(20) NOT NULL,date int(11) DEFAULT "0" NOT NULL,readsign tinyint(4) DEFAULT "0" NOT NULL,body varchar(200) NOT NULL,PRIMARY KEY (id),UNIQUE id_2 (id),KEY id (id));其中 sender 是发送人的 Namereceiver 是接受人的 Namedate 是发言的时间readsign 发言是否已经阅读过body 发言内容2 显示在线用户的头像<?$onlineresult = mysql_query("select Name,NickName,Face,EnterTimes from userinfo where OnlineStatus=1 and CurrentDate >".(date("U")-120));$onlinenumber = mysql_num_rows($onlineresult);echo "欢迎光临,共有:".$onlinenumber."位朋友在线,按头像发短信息:";for($i=0;$i<$onlinenumber;$i++){if(!$onlineuser = mysql_fetch_array($onlineresult))break;echo "<a onClick=MM_openBrWindow("shortalk.php?talkto=".$onlineuser["Name"]."","".$onlineuser["Name"]."","width=300,height=250")><img src="images/face/".$onlineuser["Face"].".gif" width=20 height=20 ";if($name == $onlineuser["Name"])echo "border=1 ";echo " title="代号:".$onlineuser["Name"]."昵称:".$onlineuser["NickName"]."来访:".$onlineuser["EnterTimes"].""></a>";}?>其中的 onClick 用于弹出发送消息的对话窗口,大家可以在网页的源代码里面看到