i am trying to sort out array items linking child objects to their parent from information pulled from a single mysql table. and its getting a little confusing so i am hoping someone can maybe point me in the right direction on this.
i have a mysql table with the following fields:
id = auto incrementing primary key int
root = id of the childs parent object
sort = sort order of item
title = title for the item
link = link that will be used by script
the array i have the data in looks like this.
$menu[$a[id]] = array (
"sort" => "$a[sort]",
"title" => "$a[title]",
"root" => "$a[root]",
"link" => "$a[link]"
);
array(22) {
[1]=>
array(4) {
["sort"]=>
string(1) "0"
["title"]=>
string(3) "Title 1"
["root"]=>
string(1) "0"
["link"]=>
string(0) ""
}
[2]=>
array(4) {
["sort"]=>
string(1) "1"
["title"]=>
string(6) "Title 2"
["root"]=>
string(1) "0"
["link"]=>
string(0) ""
}
[3]=>
array(4) {
["sort"]=>
string(3) "100"
["title"]=>
string(18) "Sub Item"
["root"]=>
string(1) "1"
["link"]=>
string(0) ""
}
so basically i want to out put this data so that they will be outputted in a heirarchy.
for example
<table>
<tr>
<td>
Title 1
</td>
</tr>
<tr>
<td>
Sub Item
</td>
</tr>
</table>
<table>
<tr>
<td>
Title 2
</td>
</tr>
</table>