title: Private Messaging System With Threading/Replies
body: <p>I'm currently working on creating a private messaging system, (PHP/MySQL) in which users can send message to multiple recipients at one time, and those users can then decide to reply.</p>
  
  <p>Here's what I'm currently working with:</p>
  
  <pre><code>tbl_pm tbl:
  id
  date_sent
  title
  content
  status ENUM ('unread', 'read') DEFAULT 'unread'
  
  tblpm_info tbl:
  id
  message_id
  sender_id
  receiver_id
  </code></pre>
  
  <p>However, I need some help determining the logic on two things:</p>
  
  <p>1) When a new message is created, should the "id" be auto-increment?  If the 'id' column is set to auto-increment in both tables, how would I set the "message_id" column in the 'relation table'?</p>
  
  <p>For example, when a new message is created, my MySQL statement is as follows:</p>
  
  <pre><code>&lt;?php
  mysql_query("INSERT INTO `tblpm` (title, content, sender_id, date_sent) VALUES ('$subject', '$message', '$sender', NOW())" );
  </code></pre>
  
  <p>In the same statement, how would I enter the 'auto-incremented' value of tblpm into the tblpm_info "message_id" field?</p>
  
  <p>2) What should my MySQL statement look like when users reply to messages?</p>
  
  <p>Perhaps I am making this more complicated than I need to.  Any help is greatly appreciated!</p>