Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Budowanie drzewa z tablicy
Mayka
post
Post #1





Grupa: Zarejestrowani
Postów: 304
Pomógł: 1
Dołączył: 12.01.2009
Skąd: Kanapa

Ostrzeżenie: (0%)
-----


Witam,
mam taki problemik... potrzebuje zrobić liste <ul><li> z tabeli.. niby pierdoła ale mam problem bo musze sprawdzić czy ma 'dzieci'.
tabela wyglada tak ->
  1. [0] => Array ( [id] => 2 [type] => [name] => asd [parent] => 1 )
  2. [1] => Array ( [id] => 49 [type] => [name] => asd [parent] => 0 )
  3. [2] => Array ( [id] => 48 [type] => Galeria [name] => Galeria [parent] => 0 )
  4. [3] => Array ( [id] => 24 [type] => 0 [name] => Home [parent] => 1 )
  5. [4] => Array ( [id] => 1 [type] => 0 [name] => Home2 [parent] => 0 )
  6. [5] => Array ( [id] => 39 [type] => formularz [name] => Kontakt [parent] => 1 )
  7. [6] => Array ( [id] => 33 [type] => [name] => sdfsdfsd [parent] => 1 )
  8. [7] => Array ( [id] => 25 [type] => 0 [name] => Druga strona [parent] => 1 ) )


A struktura musi wyglądać tak:
  1. <ul>
  2. <li id="id1" rel="folder"><a href="#">some category 1</a>
  3. <ul><li ><a href="#">some text</a></li></ul>
  4. <ul><li ><a href="#">some text</a></li></ul>
  5. <ul><li ><a href="#">some text</a></li></ul>
  6. <ul><li ><a href="#">some text</a></li></ul>
  7. <ul><li id="id1" rel="folder"><a href="#">some category 3</a>
  8. <ul><li ><a href="#">some text</a></li></ul>
  9. <ul><li ><a href="#">some text</a></li></ul>
  10. <ul><li ><a href="#">some text</a></li></ul>
  11. <ul><li ><a href="#">some text</a></li></ul>
  12. </li></ul
  13. </li>
  14. <li id="id2" rel="folder"><a href="#">some category 2</a>
  15. <ul><li ><a href="#">some text</a></li></ul>
  16. <ul><li ><a href="#">some text</a></li></ul>
  17. </li>
  18. </ul>


Jeśli ma potomków to jest rel="folder" tylko teraz jak to sprawdzić ?

Ten post edytował Mayka 7.11.2012, 14:37:06
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.12.2025 - 19:46