<?php session_start() ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include("conn.php");
if($_SESSION['username']=='')
{
$_SESSION['username']="-----";
}
$sql="select guestmail,guestaddress,chattime,message,sendto from chat_message where guestmail='".$_SESSION['username']."' || username='".$_SESSION['username']."' order by id desc limit 0,100";
mysql_query("set names 'utf8'",$dbconn);
$result=mysql_query($sql,$dbconn);
$rows=mysql_num_rows($result);
for($i=0;$i<$rows;$i++)
{
if(mysql_result($result,$i,'guestmail')==$_SESSION['username']){
echo "<a href='#' style='color:#C47B55;' onclick=\"getuserinfo('".mysql_result($result,$i,'sendto')."','".mysql_result($result,$i,'guestmail')."')\">".mysql_result($result,$i,'guestmail').":".mysql_result($result,$i,'guestaddress')."-".mysql_result($result,$i,'chattime')."</a>:<font color='green'>";
}else{
echo "<a href='#' onclick=\"getuserinfo('".mysql_result($result,$i,'sendto')."','".mysql_result($result,$i,'guestmail')."')\">".mysql_result($result,$i,'guestmail').":".mysql_result($result,$i,'guestaddress')."-".mysql_result($result,$i,'chattime')."</a>:<font color='green'>";}
echo mysql_result($result,$i,'message');
echo "</font><br />";
}
mysql_close($dbconn);
mysql_free_result($result);
 ?>