I seem to have a problem:

Using the following code I get the following result:

PHP Code:
//Grab all the main cats and store them in an array
$result mysql_query("select * from cats order by id");
while(
$row mysql_fetch_array($result)) {
    
extract($row);
    
$cats[$id] = array("titel" => $titel,
                       
"subcats" => array()
                       );
    }

//Get all the subcats and put them into the array at the corresponding main cat    
$result mysql_query("select * from subcats order by cat");
while(
$row mysql_fetch_array($result)) {
    
extract($row);
    
$cats[$cat.ID]["subcats"][$id] = $titel;
    }    
    
    
foreach(
$cats as $key => $val) {
    print 
"Cat $key ".$cats[$key]["titel"]."<br>";
    
$i 1;
    foreach(
$cats[$key]["subcats"] as $jey => $jal) {
        print 
"&nbsp;&nbsp;&nbsp;Subcat $key.$i $jal<br>";
        
$i++;
        }
    unset(
$i);    
    print 
"<br><br>";
    } 
----------
Category 1 University

Category 2 Education development

Category 3 Professionalising Education

Category 4 Organisation

Category 1ID
...Subcat 1ID.1 university of leiden
...Subcat 1ID.2 blablablablabla

Category 2ID
...Subcat 2ID.1 education blablabla
...Subcat 2ID.2 education blabladidid
...Subcat 2ID.3 education blakjlsdl

Category 3ID

et cetera, et cetera.
-----------
(subcats without the dots at the beginning)

The tables I have are:
cats
- id
- titel

subcats
- id
- cat
- titel

What I want to show is:

'Category 1 title'
... subcategory 1.1 title
... subcategory 1.2 title

'Category 2 title'
... subcategory 2.1 title
... subcategory 2.2 title
---
so with the example used above it should look like this:
---
University
... university of Leiden
... blablablablabla

Education development
... education blablabblab
... education ball9d9d9
... education skjlkf lkj blablabla
---

Somehow it does find the names (titel) for the categories, prints them and then it uses the id's for the categories and prints the subcats... we're almost there.

PS: this is part of a final year project I have to do for my study... (internship at the University)