|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Tree Structure Question.
Hi!
Currently I'm using a tree like sections structure, e.g. Code:
Table: sections +--------+------------+----------+ | sec_id | sec_parent | sec_name | +--------+------------+----------+ | 1 | 1 | Home | | 2 | 1 | News | | 3 | 2 | Sports | | 4 | 3 | Soccer | | 5 | 4 | Teams | | 6 | 5 | Arsenal | | 7 | 1 | World | | 8 | 7 | England | | 9 | 8 | Economy | +--------+------------+----------+ Also I'm using the function below to cover the tree: PHP Code:
The above function will return: ------------------------------------ Home News News > Sports News > Sports > Soccer News > Sports > Soccer > Teams News > Sports > Soccer > Teams > Arsenal World World > England World > England World > England > Economy ------------------------------------ I would like to see only subsections below the section Sports, (sec_id = 3), thus my sections_tree should be represented, -------------------------------------- Sports Sports > Soccer Sports > Soccer > Teams Sports > Soccer > Teams > Arsenal -------------------------------------- The question is: How could I improve this function to show only subsections below a pre-determined section??? Any ideas!?!? Kindest Regards, marcoBR BTW, sorry 4 my english ... Last edited by marcoBR : December 5th, 2002 at 09:42 PM. |
|
#2
|
|||
|
|||
|
>>I would like to see only subsections below the section Sports, (sec_id = 3), thus my sections_tree should be represented
An easy way would be to run a query to get the child records of the highest level Sec_ID you want SELECT * FROM SECTIONS WHERE Parent_ID = $SecID; and put those records into an array. Use a loop to go through the array, taking the Sec_ID from each element and running the query to find the child records of each element and put them into the array until all children have been found. Once you have found all the records and put them in the array, use a loop to get them out. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Tree Structure Question. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|