php tier board style

138 Views Asked by At

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   [email protected]   john smith1
  >>     Harry        15/12/1985     98 The Roundhay     [email protected]        harry23
    >>>    jhk          08/11/1976     65 dfgdfg           gfdfg@ yahoo.com       jhk345
4  john smith   10/11/1986    124 Peermont Drive   [email protected]   john smith1
     >>  Harry        15/12/1985     98 The Roundhay     [email protected]        harry23
        >>>> jhk          08/11/1976     65 dfgdfg           gfdfg@ yahoo.com       jhk345

Something like this

1

There are 1 best solutions below

1
On BEST ANSWER

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);
    }
}