Chat room Php&mysql (iv) _php tutorial

Source: Internet
Author: User
Fourth page name= "index.php"

Include ". /signup/mysql.php ";
Header ("Expires:sun, Dec 1997 09:32:45 GMT");
Header ("Cache-control:no-cache, must-revalidate");
Header ("Pragma:no-cache");
Header ("content-type:text/html; Charset=${charset} ");

?>



<title>Charmain</title>







$max _row_length=30;

$select = "Select row from User_message order by row DESC";
$result =mysql_query ($select) or Die ("false fgfg");
$rowlist =mysql_fetch_array ($result) or Die ("false");
$max _row= $rowlist ["Row"];


if ($max _row> $max _row_length) {


$delete _row= $max _row-$max _row_length+1;

echo $max _row. "
". $delete _row;
$select = "Select row from User_message where row<". $delete _row;
$result =mysql_query ($select) or Die ("false");
while ($row =mysql_fetch_array ($result))
{
$sql = "Delete from user_message where row <". $delete _row;

mysql_query ($sql) or Die ("Del false1");
}


$left = $delete _row;
}

else {$left = 1;

}

for ($i = $max _row; $i >= $left; $i-)
{
$sql = "Select Message,userid,object,status,color,action1,time1 from User_message where row= ' $i '";
$result =mysql_query ($sql) or Die (Mysql_error ());
$row =mysql_fetch_array ($result);
$time 1= $row ["time1"];

$usert 1= $row ["userid"];
$OBJECTT 1= $row ["Object"];
$sql = "SELECT id from chat_user_list where userid= ' $usert 1 '";
$result =mysql_query ($sql) or Die (Mysql_error ());
$rowt 1=mysql_fetch_array ($result);
$usert 5= $rowt 1["id"];

$sql = "SELECT id from chat_user_list where userid= ' $OBJECTT 1 '";
$result =mysql_query ($sql) or Die (Mysql_error ());
if ($rowt 2=mysql_fetch_array ($result))
$BOJECTT 5= $rowt 2["id"];
else $BOJECTT 5 = "everyone";



if ($row ["userid"]!= $userid) {

$user 1= "". $usert 5. "";
}
else $user 1= $usert 5;
if ($row ["Object"]!= $userid) {

$user 2= "". $BOJECTT 5. ""; }
else $user 2= $BOJECTT 5;
$message 2= $row ["message"];
$message 3=htmlspecialchars ($message 2);

$message 1 = " ". $user 1."To ". $user 2." ". $row [" Action1 "].":". $message 3.";

if ($row ["status"]==1) {
if ($row ["Object"]== $userid | | $row ["userid"]== $userid)
echo "Private chat". $time 1. " ". $message 1."
";
else continue;
}
else {
echo $time 1. " ". $message 1."
";

}
}

?>


http://www.bkjia.com/PHPjc/315984.html www.bkjia.com true http://www.bkjia.com/PHPjc/315984.html techarticle page Fourth of name=index.php. Include: /signup/mysql.php; Header (Expires:sun, DEC 1997 09:32:45 GMT); Header (Cache-control:no-cache, must-revalidate); Header (PRAGMA:NO-CAC ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.