Forum Moderators: coopster
Is it difficult to build a hierarchical tree from a table that has a parent field. Imagine that the table was:
Cat ¦ Parent
1¦ null
2¦1
3¦1
4¦3
5¦3
6¦1
is it difficult to get the following:
1
--2
--3
----4
----5
--6
If possible does anyone know of and good examples of this online so I can learn from it.
Cheers
Slicker would be to incorporate each record's heirarchy level in a system-assigned id field (if thats not in your table definition yet).
You could then do an str_repeat("-", <heirarchylevel>) in the resultset display loop, like so...
while (!eof) {
echo str_repeat(" ", sqlresultset->fields("hLevelID"));
echo sqlresultset->fields("AcctID")."<br>\n";
}
It'd cost you a few bytes per record, but does allow you to do the formatting with a single query.
magicke