<?php 
$message_id=$_POST["message_id"];
$rolenumber=$_SESSION["rolenumber"];
$result_message=$dbh->query("select * from message where messageid='$message_id' order by autoid asc");
$row_message=$result_message->fetchObject();

echo "
<table width='100%' border='0'>"; 

do{
if($rolenumber==$row_message->sender){

echo "
<tr>
<td width='40%'></td>
<td width='20%'></td>
<td width='40%' align='right'>
<div style='color:#3c763d;border-radius:10px;padding:20px;background-color:#dff0d8;font-size:15px;margin-bottom:2px;word-wrap:break-word;'>
".$row_message->message."";
/*if($row_message->dateread!=''){
echo "<img src='img/tick.png' style='height:18px;float:right;margin-left:10px;'>";
}*/
echo "
<span style='float:left;font-size:12px;'>".$row_message->dater."</span>
</div>
</td>

</tr>
";	
}else{
echo "
<tr>
<td width='40%' align='left'>
<div style='color:#333;border-radius:10px;padding:20px;background-color:#d9edf7;font-size:15px;margin-bottom:2px;word-wrap:break-word;'>
".$row_message->message."
<span style='float:right;font-size:12px;'>".$row_message->dater."</span>
</div>
</td>
<td width='20%'></td>
<td width='40%'></td>
</tr>"; 
}
}while($row_message=$result_message->fetchObject());

echo "
</table>";
?>