PHP and mysql To Display Chat Messages in WhatsApp Style of Grouping by Date
<p>Can anyone guide me on how to display all messages from my chat database table in WhatsApp format Grouping Messages by Date i.e</p>

<blockquote>
  <p>[Today]</p>
  
  <p>Janet:How are?</p>
  
  <p>Jon: Am fine and you</p>
  
  <p>[ Yesterday ]</p>
  
  <p>John: Go to bed please</p>
  
  <p>Janet: Okay dear, Good nite</p>
  
  <p>[19 May, 2016 ]</p>
  
  <p>John: Go to bed please</p>
  
  <p>Janet: Okay dear, Good nite</p>
</blockquote>

<p>Mysql:</p>

<pre><code>CREATE TABLE IF NOT EXISTS `chat` (
  `id` int(10) unsigned NOT NULL,
  `from` varchar(255) NOT NULL DEFAULT '',
  `to` varchar(255) NOT NULL DEFAULT '',
  `message` text NOT NULL,
  `sent_by` varchar(111) NOT NULL,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `recd` int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=MyISAM AUTO_INCREMENT=229 DEFAULT CHARSET=latin1;  
</code></pre>

<p>PHP:</p>

<pre><code>$result = mysql_query("SELECT *FROM (SELECT * FROM `chat` WHERE `from` = '$my_id' AND `to` = '$chat_with' OR `from` = '$chat_with' AND `to` = '$my_id' ORDER BY `created`  DESC  LIMIT $start, $limit )tmp 
ORDER BY tmp.created ASC") or die(mysql_error());

while($row = mysql_fetch_array($result)){
print"$row['from']";
 echo parse_smileys(make_clickable(nl2br(stripslashes($row['message']))), $smiley_folder);
  print"$row['created'] @ $msg_time";
}
</code></pre>