Grazie Portapipe per la risposta.
Nel mentre ho trovato questa funzione che si autorichiama in continuo.
In teoria non è il massimo in fatto di prestazioni, salvo non avere milioni di categorie e sottocategorie annidate.
Codice PHP:
// $parent is the parent of the children we want to see
// $level is increased when we go deeper into the tree,
// used to display a nice indented tree
function display_children($parent, $level) {
// retrieve all children of $parent
$get_data = "SELECT * FROM tabella WHERE parent_ID='" . $parent . "'";
$result = mysql_query($get_data);
// display each child
while ($row = mysql_fetch_array($result)) {
// indent and display the title of this child
print str_repeat('', $level). " <input type=\"radio\" name=\"parent\" value=\"" . $row["ID"] . "\" />" . $row['nome']."
\n";
// call this function again to display this
// child's children
display_children($row['ID'], $level+1);
}
}
Richiamando la funzione e passandogli i parametri di $parent = "" (ovvero nulla) e $level = 0, ti mostra tutta la struttura, oltretutto con i nomi "indentati".
Preso da qui: http://www.sitepoint.com/hierarchical-data-database/