jazztie, I think I've pinpointed the problem.
This line:
$cats[$cat.ID]["subcats"][$id]*=*$titel;
Should be:
$cats[$Cat_ID]["subcats"][$id]*=*$titel;
I think that's the problem. Putting this post into a new thread was not a good idea, because I had to go back to your original post to find the database schema to find that bug 
Looking at your database schema, BTW, I do not think its necessary to have two tables. Is not a subcategory just a category? (is a circle really just an elipse?) To me they are the same things because they have the same attributes (id and a title). The additional thing you need to model is the relationship that causes one category to be a sub-cateogory of another category. Where an entity is related to none or one other entities of the same type, this is a tree data structure which can be represented using just the one table.
Lets use your example data:
University
... university of Leiden
... blablablablabla
Education development
... education blablabblab
... education ball9d9d9
... education skjlkf lkj blablabla
Now lets represent this as a data tree using this schema
Cateogry(ID, Title, Parent)
Code:
Category
------
ID | Title | Parent
--------------------------------
1 | University | NULL
2 | Education development | NULL
3 | blablablablabla | 1
4 | education blablabblab | 2
5 | education ball9d9d9 | 2
6 | education skjlkf lkj blablabla | 2
Then to get the table data into the array structure (and copy-and-pasting some of freddy's code)
PHP Code:
$result*=*mysql_query("select***from*Categories*order*by*Parent, ID");
while($row = mysql_fetch_array($result) {
extract($row);
if ( is_null($Parent) ) {
$cats[$ID] =*array("titel"*=>*$titel,
"subcats"*=>*array());
} else {
*$cats[$ID]["subcats"][$id]*=*$titel;
}
}
I hope that is of some help, seeing as it is for a academic project I thought that it might be an idea to look at the data-strucure you are using. Anyone feel free to tell me my way is stupid or that there is a better way of modelling/codeing this
Bookmarks