title: Building a tree view
body: <p>I'm a little stumped on this problem and I've been thinking about it for a while now. I have a table in my DB that holds a tasks. Each task can have a parent task by holding it's primary key in the parent_id field. I have no limit on how deep these tasks can be linked.</p>
  
  <pre><code>+-----------+-------+-----+
  | Field     | Type  | Key |
  +-----------+-------+-----+
  | id        | int   | PRI |
  | parent_id | int   | MUL |
  +-------------------+-----+
  </code></pre>
  
  <p>A task without a parent_id is a "project" and all tasks can be grouped in task groups by sharing a parent task. I would now like to populate a HTML select box with all the descendant of the project.</p>
  
  <pre><code>Task 1
    -Task 1.1
    -Task 1.2
      -Task 1.2.1
      -Task 1.2.2
    -Task 1.3
  Task 2
  </code></pre>
  
  <p>How can I go about this? I figure some sort of recursive function is in order but I can't seem to really figure how to go about it.</p>
  
  <p>Any help would be greatly apprecaited. :)</p>