per la serie: si trova una soluzione subito dopo averla richiesta 
Codice PHP:
function buildThree($root) {
// retrieve the left and right value of the $root node
$result = mysql_query('SELECT sx, dx FROM personale '.
'WHERE id="'.$root.'";');
$row = mysql_fetch_array($result);
// start with an empty $right stack
$right = array();
// now, retrieve all descendants of the $root node
$result = mysql_query('SELECT nome, sx, dx FROM personale '.
'WHERE sx BETWEEN '.$row['sx'].' AND '.
$row['dx'].' ORDER BY sx ASC;');
// display each row
while ($row = mysql_fetch_array($result)) {
// only check stack if there is one
if (count($right)>0) {
// check if we should remove a node from the stack
while ($right[count($right)-1]<$row['dx']) {
array_pop($right);
}
}
// display indented node title
echo str_repeat('__',count($right)).$row['nome']."
\n";
// add this node to the stack
$right[] = $row['dx'];
}
}
Codice PHP:
buildThree(1);
che mi restituisce questo:
Codice PHP:
Massimiliano
__Francesco
____Mario
____Luigi
____Fabio
______Piero
________Marco
______Gianni
____Gianni
boh... non ne sono del tutto convinto, ma sembra funzionare