Well, this actually looks like it belongs in the 'coding help' forum, however I'll give you a couple of hints (at least on how I solve this problem).
You have a table with msg_id and parent_id, as you say, and in addition ofcourse authour, message data, blah blah blah. What you need, is a recursive function! (E.g. a function that calls itself).
A message that is actually the start of a new thread, would have parent_id set to 0. So, first you need to do is select a nice set of thread start messages, e.g. SELECT * FROM messages WHERE parent_id=0 ORDER BY created DESC LIMIT 0,20 .. or something like that. Now, print whatever headline, info etc you need about this message, and call a function something like:
show_thread_children($msgID, $step) {
$res = mysql_query(..SELECT * FROM messages WHERE parent_id=$msgID");
while ($oneReply = mysql_fetch_array($res) {
print '<tr><td>'.make_stepping($step).$oneReply[title].'</td></tr>
show_thread_children($oneReply[msg_id], $step++);
}
}
And you'd have to write a make_stepping function to create $step number of blanks, tabs, chickens or whales in front of each title. And you probably want to make them links, print authors, dates, bla bla bla.
hopefully it gave you the basic idea though 😉