Well even i'm facing a similar proble....I've been trying to construct the logic but failed...My Database structure stores the thread id which is a autoincremented field and the parent id which for a root node is zero.
A solution given by one person was to write a function showthreads wherein you pass the threadid. This function will query the corresponding forums table (having seperate tables for each forum created by the Admin) for the thread id passed and retrieve all the child threads (i.e parentid = threadid) and this function is going to be called recursively in a while-loop. This means there are going to be so many database queries and avoid so many queries.....
I shall take a look at sourceforge.net to get some ideas....