mam problem z wstawieniem zawartości drzewa do listy numerowanej.
Używam takiego kodu do tworzenia listy:
<? function pokaz_inf($id) { $tmp = 0; foreach($t as $element) if ($element['rodzic']==$id) $wynik[] = $element; foreach($wynik as $element) { $ch = false; if ($element['type']=='folder') foreach ($t as $element2) { if ($element2['id']==$element['rodzic']) { $ch = true; break; } } if ($ch==false && $element['type']=='folder') $tmp++; pokaz_inf($element['id']); } } $result = query('SELECT * FROM `info_tree` ORDER BY `order`'); if ($result) { 'nazwa'=>$dane['node_name'], 'element_id'=>$dane['element_id'], 'type'=>$dane['type']); } } pokaz_inf(0); ?>
Problem w tym, że nie wiem jak sprawdzić, w którym momencie mam zamknąć odpowiedni znacznik <ul> i <li>. W kodzie widać moje niezbyt udolne próby... Struktura tabeli:
CREATE TABLE `info_tree` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pid` int(11) NOT NULL, `element_id` int(11) DEFAULT NULL, `type` text NOT NULL, `order` tinyint(4) NOT NULL, `node_name` text NOT NULL, PRIMARY KEY (`id`) )
Bardzo proszę o pomoc.
Pozdrawiam