


my summer holiday English composition using PHP+MySql to write a chat room
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);
?>
if(!isset($username))
$username="guest";
if(!isset($yanse))
$yanse="blue";
if(!isset($objectname))
$objectname="大家";
?>
if(isset($username)&&isset($fayan)){
$c
mysql_select_db("database",$conid);
$sql="insert chat (username,objectname,action,msg,color) values ("$username","$objectname","NO","$fayan","$yanse")";
mysql_query($sql,$conid);
mysql_close($conid);
}
?>
$c
mysql_select_db("database",$conid);
if(!isset($username))
$username="getmsg";
$dt=time();
$newdate=date("YmdHis",$dt);
$fromdate=date("YmdHis",$dt-6);;
$sql="select username as name,msg,action,objectname ,shijian,color from chat where shijian>="$fromdate"";
$res=mysql_query($sql,$conid);
echo "n";
echo "n";
echo "n";
?>
if(!isset($username))
$username="guest";
echo "n";
echo "n";
echo "n";
?>
欢迎光临
在线人数
if(!isset($username))
$username="guest";
$dt=time();
$newdate=date("YmdHis",$dt);
$fromdate=date("YmdHis",$dt-200);
$linkid=mysql_connect("localhost","yourcount","password");
mysql_select_db("yourdatabase",$linkid);
$sql="update chat_getmsg set shijian="$newdate" where username="$username"";
mysql_query($sql,$linkid);
$sql="select username from chat_getmsg where shijian>="$fromdate"";
$res=mysql_query($sql,$linkid);
while(list($username)=mysql_fetch_row($res)){
echo "$username
n";
$fromdate=date("YmdHis",$dt-100);
$sql="delete from chat where shijian<="$fromdate"";
mysql_query($sql,$linkid);
mysql_close($linkid);
}
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
以上就介绍了my summer holiday英语作文 用PHP+MySql编写聊天室,包括了my summer holiday英语作文方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
