Sorry that's not a very good subject line, I'm pretty new to the whole PHP and MySQL thing. Basically, I've got the following table in MySQL:
So basically, as you can see we've got a company called my comp. Then we've got 2 divisions in there, Div1 and Div2. In Div1, we've got 2 depattmetns, A & B and in Div2 we've got departments C & D. What I want know is how to I echo out the hierarchy. So far, I've got
I can echo it all out, but say I want to put a Div (say in blue) to show the company, then another div with the divisions and then their departments underneath that, how can I go about it? I don't want to introduce levels because the company pretty much has sub-departments within departments - not a very structured hierarchy. Can anybody help me do this at all?
Code:
OUID OU_Name Parent_OU
1 MyComp <blank>
2 Div1 1
3 Div2 1
4 DepA 2
5 DepB 2
6 DepC 3
7 DepD 3
So basically, as you can see we've got a company called my comp. Then we've got 2 divisions in there, Div1 and Div2. In Div1, we've got 2 depattmetns, A & B and in Div2 we've got departments C & D. What I want know is how to I echo out the hierarchy. So far, I've got
Code:
$get_hierarchy = mysql_query("SELECT * FROM hierarchy ORDER BY OUID");
$hierarchy = mysql_fetch_array($get_hierarchy);