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