Hi
| cat_id | parent_id | title |
| 001 | 0 | PC |
| 002 | 0 | Autos |
| 003 | 002 | VW |
| 004 | 002 | Audi |
| 005 | 002 | Mercedes |
| 006 | 002 | Toyota |
| 007 | 001 | Software |
| 008 | 001 | Hardware |
| 009 | 007 | Programme |
| 010 | 009 | Windows |
| 011 | 009 | Linux |
| 012 | 008 | CPU |
| 013 | 008 | Board |
| 014 | 008 | Karten |
| 015 | 012 | Grafik |
| 016 | 012 | TV |
| 017 | 012 | Modem |
| 018 | 012 | LAN |
| 019 | 012 | Kombi |
select cat_id, parent_id, title from tabelle order by parent_id asc, cat_id asc;
Das Ergebnis dieser Abfrage holst Du Dir in ein Array oder arbeitest direkt mit fetch() (Frag' mich jetzt bitte nicht nach der syntax des fetch-Kommandos).
Wenn aktuelle_parent_id gleich der vorangegangenen, dann bist Du im aktuellen Knoten.
Wenn aktuelle_parent_id ungleich der vorangegangenen, dann bist Du in einem neuen Knoten.
Ich hoffe, das hilft Dir etwas.
Gruß
Hans