chatroom help
Posted: Sat May 23, 2009 9:28 pm
i need help.. im making this simple chatroom and i want to add emoticons to the message..
pls give me an idea how to do it.. just a simple idea would do.. I couldn't find something useful about it in Google..
moreover, for example the user enters this message:
"I am happy
Are u?"
When it is displayed in the window message, here is the displayed message:
"I am happy Are u?"
how do i go about making the "Are u" text go below as inputted by the user.. I want it to appear exactly as the user inputted it..
Here is my code for displaying the message :
thanks in advance
pls give me an idea how to do it.. just a simple idea would do.. I couldn't find something useful about it in Google..
moreover, for example the user enters this message:
"I am happy
Are u?"
When it is displayed in the window message, here is the displayed message:
"I am happy Are u?"
how do i go about making the "Are u" text go below as inputted by the user.. I want it to appear exactly as the user inputted it..
Here is my code for displaying the message :
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
require 'db/db_connect.php';
require 'db/session.php';
$id=$_SESSION['id'];
?>
</head>
<meta http-equiv="refresh" content="1">
<body bgcolor=#ffffff>
<table id=smallfont>
<?php
$sql1=mysql_query("SELECT maintime, chatid, message from mainchat ORDER BY maintime");
$rows=mysql_num_rows($sql1);
@mysql_data_seek($sql1,$rows-15);
//if the number of messages<15, get all of the messages
if ($rows<15) $l=$rows;
else $l=15;
for ($i=1;$i<=$l; $i++) {
list($maintime, $chatID, $message)=mysql_fetch_row($sql1);
$sql2=mysql_query("SELECT username from person where personID='$chatID'");
$result2=mysql_fetch_array($sql2);
$username=$result2[0];
echo "<b> "; echo $username; echo":</b>   " ; echo $message; echo " <br>";
}
//delete the old messages(only keep the newest 30 only)
@mysql_data_seek($sql1,$rows-30);
list($limtime)=mysql_fetch_row($sql1);
$str="DELETE FROM mainchat WHERE maintime<'$limtime' ;";
$result=mysql_query($str);
?>
</table>
</body>
</html>