Home >php教程 >php手册 >采用行写方式的聊天程序(之二)

采用行写方式的聊天程序(之二)

WBOY
WBOYOriginal
2016-06-13 10:31:02773browse

lt1.php(做为现在的主流开发语言):
该程序为整个系统的入口,含有两个全局参数:chat_hh,uname分别记录当前最大的发言序号和发言者名称


session_start();
session_register("chat_hh");
session_register("uname");


//取数据库最大编号
include("g_fun.php(做为现在的主流开发语言)");
f_connectdb();
$query  = "select max(lt_id) as rmaxid from lt_t_content";
$res = MySQL(和PHP搭配之最佳组合)_query($query, $dbh);  
$row = MySQL(和PHP搭配之最佳组合)_fetch_array($res);
$f_chat_hh =  $row["rmaxid"];
if (empty($f_chat_hh)) { $f_chat_hh = 0; }
if ($f_chat_hh > 12 ) {
   $chat_hh=$f_chat_hh - 12;
} else
$chat_hh=$f_chat_hh;

$un_len=strlen($name);
$uname=$name;

//增加在线人员信息
$query  = "select count(*) as rcount from lt_t_online where lt_username = ".$name."";
$res = MySQL(和PHP搭配之最佳组合)_query($query, $dbh);  
$row = MySQL(和PHP搭配之最佳组合)_fetch_array($res);
$lcount =  $row["rcount"];
if ($lcount == 0) {
   $query  = "insert into lt_t_online(lt_username,lt_lasttime) values(";
   $query .= "".$name.",now())";
   $res = MySQL(和PHP搭配之最佳组合)_query($query, $dbh);  
}
$query  = "update lt_t_online set lt_lasttime = now(),lt_state = 0 ";
$query .= " where lt_username = ".$name."";
$res = MySQL(和PHP搭配之最佳组合)_query($query, $dbh);  
?>


php<font class="reblank">(做为现在的主流开发语言)</font>无刷新感聊天室





  
  
  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn