I'm just wondering if you can help me organize the query result from many to many relationship, below are other details. 

[![enter image description here](https://i.stack.imgur.com/4v26j.jpg)](https://i.stack.imgur.com/4v26j.jpg)  

here is my query: 

`SELECT rt.room_title as rm_name, amn.amnty_title 
FROM amenities_tbl AS amn
LEFT JOIN room_am_link AS ral ON amn.amnty_id = ral.am_id
LEFT JOIN rooms_tbl AS rt ON ral.rm_id = rt.room_id;`

and here is my foreach loop on the query result (codeigniter):

```
<?php foreach($result as $row){?>
<tr>
<td><?php  echo $row['rm_name']; ?></td>
<td><?php echo $row['am_title']; ?></td>
</tr>
<?php } ?>  

```

the display result is show below,  

[![enter image description here](https://i.stack.imgur.com/W5yCU.jpg)](https://i.stack.imgur.com/W5yCU.jpg) 

but what i want the display to be is like this image below, the room title is not repeated:  

[![enter image description here](https://i.stack.imgur.com/tdVJ0.jpg)](https://i.stack.imgur.com/tdVJ0.jpg)

i'm sorry if my questions is very long, i just want it to be clear as much as possible.  

thank you and hope you can help me guys.