Hello everyone! I haven’t seen you all for a long time. Last time I wrote about a chat room that uses PHP to operate through files. Of course it is full of loopholes, and every time I refresh the screen it is terrible! I have been thinking about it for a long time. Is there a way to get the speech information without refreshing? This effect can be achieved by using one more framework. That is, using one more framework is called getmsg. We let getmeg obtain information and ensure that the information obtained each time is the latest. That is, the speech obtained last time is not needed. Last time I edited The problem is that every time the information is obtained, it is repeated, which is not effective.
My design idea is: for every speech, submit it to the server, and then save it to a database. Getmsg will go to the server to obtain the latest speech data every few seconds, and ensure that the last speech obtained is not used. Removed it, and then superimposed the removed speech into a window (listmsg) dedicated to displaying speeches. In this way, we feel that the listmsg window will not have to be refreshed. Moreover, we can only see the speech information being added continuously, which has a very good effect.
How to add information from one frame to another frame? This idea can be realized using JavaScript:
Of course you have to create two tables in mysql, one table is used to save speech information, and one table is used to save several online ones. When listing the number of people online, we let it Refresh every 60 seconds, delete the speeches made one minute ago, and check whether a certain speaker has not spoken for a long time. If so, delete him.
Since the subsections of the table are very simple, in Don't write it out here, you will know it by looking at the program.This program works very well both online and offline!
表的名字是:chat和chat_getmsg
if(!isset($username))
$username="guest";
$c
mysql_select_db("yourdadabase",$conid);
$dstr=date("YmdHis");
$sql="insert chat_getmsg (username,shijian) values ('$username','$dstr')";
mysql_query($sql,$conid);
$sql="update chat_getmsg set shijian='$dstr' where username='$username'";
mysql_query($sql,$conid);
mysql_close($conid);
?>
以上就介绍了my summer holiday英语作文 用PHP+MySql编写聊天室,包括了my summer holiday英语作文方面的内容,希望对PHP教程有兴趣的朋友有所帮助。