Outputting data in php from sql
<p>I would like to output grouped data from mysql in php</p>

<p>The sql database:
<a href="https://i.stack.imgur.com/1tuLH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1tuLH.png" alt="enter image description here"></a></p>

<p>I have an sql statement that groups the content according to a to_id of 4.</p>

<pre><code>sql statement: select group_concat(messg) from my_table  where to_id = 4   
group by from_id;
</code></pre>

<p>I would like to view the messages in php such that i get:</p>

<pre><code>1. get: 2messages  from_id 1(messages: TRUELOVE, hadi when)
2. get: 1 msg from_id 2(message: cutie)
3. get: 1 msg from_id 3(message: true love)
</code></pre>

<p>STATEMENTS TO CONNECT TO DATABASE:</p>

<pre><code>&lt;?php
$con = mysqli_connect("localhost", "root","","bmcs" );

if(mysqli_connect_errno()){

  echo "Failed to connect to database". mysqli_connect_error();
}
</code></pre>