Nel link che ho postato ci sono le query già pronte.
Con php dovresti usare una funzione del genere ( link )
Codice PHP:
function getChildren($id=1) {
$sql = mysql_query("SELECT * FROM categories WHERE category_parent = '$id' ORDER BY lft ASC");
echo "<ul>";
while($row = mysql_fetch_array($sql)) {
echo "[*][url='/{$row[']{$row['category_name']}[/url]";
getChildren($row['category_id']);
}
echo "[/list]";
}
getChildren();
La puoi adattare ai campi della tua tabella ed eventualmente fargli restituire un array piuttosto che stampare dei tag html.
Ciao