0

I'm making a sort of a tier board style list, so each record can have its own sub-section etc, just like I have shown below. Any guidance on how it would be done?

id name         dob           address              email                  username
1  john smith   10/11/1986    124 Peermont Drive   john.smith@yahoo.com   john smith1
  >>     Harry        15/12/1985     98 The Roundhay     harry@gmail.com        harry23
    >>>    jhk          08/11/1976     65 dfgdfg           gfdfg@ yahoo.com       jhk345
4  john smith   10/11/1986    124 Peermont Drive   john.smith@yahoo.com   john smith1
     >>  Harry        15/12/1985     98 The Roundhay     harry@gmail.com        harry23
        >>>> jhk          08/11/1976     65 dfgdfg           gfdfg@ yahoo.com       jhk345

Something like this

mayman212
  • 27
  • 10
  • There was a reason for it being like that, the additional records are like comments. – mayman212 Nov 14 '11 at 10:52
  • I want to know how to make a forum like list, like I've shown above. I have the edit delete and comment links, but I need it to show like above... – mayman212 Nov 14 '11 at 10:59

1 Answers1

0

MySQL doesn't support hierarchical queries, so you can't do this with a simple SELECT. You can try emulating the hierarchical query with a stored function, example how to do this can be found here: http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/.

Alternatively, you can do this using multiple queries, in PHP, using recursion:

function print_row_and_children($row, $level = 0) {
    out_ident($level);
    out_row($row);
    foreach (get_children($row) as $child) { 
        print_row_and_children($child, $level + 1);
    }
}
socha23
  • 10,171
  • 2
  • 28
  • 25
  • how about if i wanted it to show like a forum? when I hit the comment button< i want it to show a blank form along with the record details at the top of the page, so its basically just like a forum. – mayman212 Nov 14 '11 at 16:21