'; echo '

' . $note['ownername'] . '


'; echo '
complete tree
'; function list_brothers_and_children() { global $brothers, $children, $note, $user, $can_new; echo '
'; foreach($brothers as $b) { if ($b['id'] == $note['id']) { echo '

' . $b['title'] . '

'; foreach($children as $nn) { echo '

' . $nn['title'] . '

'; } if ($can_new) { echo '

+ new note

'; } echo '
'; } else { echo '

' . $b['title'] . '

'; } } if ($can_new) { echo '

+ new note

'; } echo '
'; } echo '
'; $did_show_up = false; foreach($user_root_notes as $n) { if ($n['id'] == $note['id']) { $did_show_up = true; echo '

' . $n['title'] . '

'; foreach($children as $nn) { echo '

' . $nn['title'] . '

'; } if ($can_new) { echo '

+ new note

'; } echo '
'; } else { echo '

' . $n['title'] . '

'; if ($n['id'] == $note['parent_id']) { $did_show_up = true; list_brothers_and_children(); } } } if ($can_new) { echo '

+ new note

'; } echo '
'; if (!$did_show_up) { echo '

'; echo '' . $note['parent_title'] . ''; list_brothers_and_children(); } */ // *** NEW WAY $notes_tree = array(); $notes_parents = array(); $n = sql("SELECT id, parent, title FROM notes ". "WHERE owner = " . $note['owner'] . ($note['owner'] == $user['id'] ? " " : " AND public != 0 ") . "ORDER BY title ASC"); while ($nn = mysql_fetch_assoc($n)) { $notes_parents[$nn['id']] = $nn['parent']; if (isset($notes_tree[$nn['parent']])) { $notes_tree[$nn['parent']][] = $nn; } else { $notes_tree[$nn['parent']] = array($nn); } } $notest = array(0 => @$notes_tree[0]); for($id = $note['id']; $id != 0; $id = $notes_parents[$id]) { $notest[$id] = @$notes_tree[$id]; } echo '
'; echo '

' . $note['ownername'] . '


'; echo '
complete tree
'; function n_tree_branch($id) { global $notest, $note, $can_new; if (!isset($notest[$id])) return; foreach($notest[$id] as $branch) { if ($branch['id'] == $note['id']) echo '

' . $branch['title'] . '

'; else echo '

' . $branch['title'] . '

'; if (isset($notest[$branch['id']])) { echo '
'; n_tree_branch($branch['id']); echo '
'; } else if ($can_new && $branch['id'] == $note['id']) { echo '
'; if ($can_new) echo '

+ new note

'; echo '
'; } } if ($can_new) echo '

+ new note

'; } echo '
'; n_tree_branch(0); echo '
';