按字段分组结果

Am building a messaging system for a site, but i want it to have an instant messaging app feel. I have table with a structure like this:

<!-- language: lang-none -->
id
R_id     = Reciever's id
S_id     = Sender's Id
message
read     = 0 if unread, 1 if read
post_time
conv_id  = conversation id

I am trying to build a query that retrieves all messages pertaining to a receiving user and display it in a group format i.e all messages from a user grouped with the user's name, sort of like facebook messages.

This is the method in my model, am working with codeigniter

function get_user_conversations($user_id) {
       //Load Models
       $this->load->model('conversation_model');
       //Load helper
       $this->load->helper('date');
       //database query
       $q = $this->db->select('*')
                     ->from('conversations_inbox')
                     ->where('R_id',$user_id)
                     ->group_by('S_id')
                     ->order_by('post_time','desc')
                     ->get();
        $conversations = $q->result();
        return $conversations;
   }

Maybe something like this?

// Presuming you want the most recent ones first
$q = mysql_query("SELECT message FROM `TABLE` WHERE `R_id`='USERNAME_HERE' ORDER BY `post_time` DESC");
while ($row = mysql_fetch_array($q)) {
  echo "<li>Message: " . $row['message'];
}

I'm honestly not really sure what you're asking, so that's the best I can do.