![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 66 Pomógł: 0 Dołączył: 1.04.2004 Ostrzeżenie: (0%) ![]() ![]() |
Witam stoje przed problemem napisania skryptu ktory wyświetlałby "ostatnie liście" w drzewie kategorii. Kożystam z rozwiązania ktore jest na sitepoint http://www.sitepoint.com/article/hierarchical-data-database/
Podaje ID rodzica np Food i chce zeby wyświetliło mi ostatnie liście czyli Cheery, Banana, Beef, Pork Siedze przy tym juz pare godzin i nie moge wpaść na pomysł, kto może ma? |
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 548 Pomógł: 2 Dołączył: 19.07.2003 Ostrzeżenie: (0%) ![]() ![]() |
witam ...
może to: Cytat If you give me the left and right values of a node, I can tell you how many descendants it has by using a little math. As each descendant increments the right value of the node with 2, the number of descendants can be calculated with: descendants = (right – left - 1) / 2 With this simple formula, I can tell you that the 2-11 ‘Fruit’ node has 4 descendant nodes and that the 8-9 ‘Banana’ node is just a child, not a parent. ostatni akapit 2 strony pozdrawiam -------------------- Computer games don't affect kids; I mean if <span style="font-weight: bold;">Pac Man</span> affected us as kids,we would all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music.
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 66 Pomógł: 0 Dołączył: 1.04.2004 Ostrzeżenie: (0%) ![]() ![]() |
ajjjj, mój angielski leży
![]() |
|
|
![]()
Post
#4
|
|
![]() Grupa: Zarejestrowani Postów: 548 Pomógł: 2 Dołączył: 19.07.2003 Ostrzeżenie: (0%) ![]() ![]() |
witam ...
Cytat descendants = (right – left - 1) / 2 Cytat liczba potomków = (prawa liczba - lewa liczba - 1) / 2 więc jeżeli większa od 0 to znaczy że ma dzieci ... umieść warunki w select z where liczba potonków = 0 i pobierze ci wszystkie ostatnie liście pozdrawiam -------------------- Computer games don't affect kids; I mean if <span style="font-weight: bold;">Pac Man</span> affected us as kids,we would all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music.
|
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 7.07.2025 - 00:29 |