Hello everyone! Long time did not see everybody, last wrote the use of PHP through the file operation of the chat room, of course, is a flawed, and every time the screen refresh is very bad! I think for a long time, is there a way not to refresh, you can get the message of the speech? Multi-use a framework can achieve this effect, that is, multi-use a framework we call getmsg, we let getmeg to obtain information and ensure that every time the information is up-to-date, that is, the last time the speech was not, the last time I made up is every time the information is repeated, so the effect is not good.
My idea is that every time I speak, I submit it to the server and then save it to a database, and in a few seconds getmsg will go to the server to get the latest statement data, and to ensure that the last statement is not taken down, and then add the statements taken down to a special display of the statement window ( LISTMSG) go. So we feel that the Listmsg window will not have a re-refresh feel and, just see the speech information constantly added, so it has a good effect,
How do you add information to another frame in one frame? This idea can be achieved with javascript:
Of course, you have to build two tables in MySQL, a table for saving the speech information, a table for saving a few online, when the number of people in the line, we let it refresh every 60 seconds, and a minute before the speech deleted, and see whether a speaker for a long time did not speak, yes, delete him,
Because the sub-section of the table is very simple, do not write here, see the program will know. This program in the online network test results are very good!
The name of the table is: Chat and chat_getmsg
if (!isset ($username))
$username = "Guest";
$conid =mysql_connect ("localhost", "yourcounter", "password");
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);
?>
<title>Untitled Document</title>
n ";?>
n ";?>
<noframes>&lt;body bgcolor= "#FFFFFF" &gt; &lt;br&gt;&lt;br&gt;&lt;/body&gt;</noframes>
if (!isset ($username))
$username = "Guest";
if (!isset ($yanse))
$yanse = "Blue";
if (!isset ($objectname))
$objectname = "Everyone";
?>
<title>Untitled Document</title>
if (Isset ($username) &&isset ($fayan)) {
$conid =mysql_connect ("localhost", "Yourcount", "YourPassword");
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);
}
?>
<title>Untitled Document</title>
$conid =mysql_pconnect ("localhost", "yourcount", "password");
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";
?>
<title>Untitled Document</title>
if (!isset ($username))
$username = "Guest";
echo " n ";
echo "n ";
echo "n";
?>
<title>Untitled Document</title>
Welcome to visit
<title>Untitled Document</title>
Number of people online
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);
}
?>
"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"
http://www.bkjia.com/PHPjc/316487.html www.bkjia.com true http://www.bkjia.com/PHPjc/316487.html techarticle Hello, everyone! Long time did not see everybody, last wrote the use of PHP through the file operation of the chat room, of course, is a flawed, and every time the screen refresh is very bad! I thought for a long time ...