![]() |
![]() |
![]()
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 |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 66 Pomógł: 0 Dołączył: 1.04.2004 Ostrzeżenie: (0%) ![]() ![]() |
ajjjj, mój angielski leży (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) ((((((((((
|
|
|
![]()
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 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 15.09.2025 - 16:10 |