I have not looked a Phorum, but here's how to follow threads.
Start with the data model, not the algorithm. A message has a serial ID and a parent ID. The latter may be null (for a root item), or may contain the ID of a parent message.
To traverse a message thread, write a function that takes an ID as an argument. The function should query the database for all messages where whose parent ID matches the passed argument. For each retrieved message, do something interesting (print out the message, print out a link, whatever you like) and -- this is important -- recursively call the function, passing the current item's ID as the argument.
Call your function with 0 as an argument and you'll start at the root level and process everything in the database.
This should be enough to get you started.
I should add that a user interface that promotes threading is pretty much guaranteed to kill any extended discussion. If you want to have conversations, keep your messages in linear presentations and branch ONLY when there is significant topic drift.
See http://stonemountain.yi.org/, click on the source code link on the left side of the page.