|
i am tring to build something like family tree
i wrote the code below and get endless herizonatl line of the head of the family...
help please!:)
imagen old and nice grandpa he got 5 sons and 4 daughters
(4+5=9)
every one of the sons got 5 sons
(5x5=25)
and every one of the daughters got 2 sons and 2 daughters
(2+2=4)
(4x4=16)
that means the grandpa got 16+25=41 grandchildren...
=>on the 1(first) level he got 9people
=>on the 2(second) level he got 41people
and may be some of the children got sons or daughters too...in that case he will got a 3(third) level too...
in my asp files, there are no replay of names=every body got his original name wich no one esle have.
i enter to the database :
"name"=firstname "gen"=personal letters key "father"=fathers personal letters key
dim level
sub GetTree(gen)
dim mySQL1, conntemp1, rst1
mySQL1="SELECT * FROM mag WHERE father='" & gen & "'"
call getFromDatabase(mySQL, rst1, "/forum/ciss.html")
if ((not rst1.EOF) and (not rst1.BOF)) then
while not rst1.EOF
for cc=1 to level
Response.Write " "
Response.Write " "
next
Response.Write rst1("name")
Response.Write "<br>"
level = level + 1
GetTree(rst1("agentcode"))
level = level - 1
rst1.movenext
wend
end if
Set rst1 = Nothing
end sub
level = 1
dim vab, mySQL, conntemp, rst
vab="Wewdrtdewew"
mySQL="SELECT * FROM mag WHERE gen='" & vab & "'"
call getFromDatabase(mySQL, rst, "/forum/cittss.html")
rst.movefirst
level=0
while not rst.EOF
for cc=1 to level
Response.Write " "
Response.Write " "
next
Response.Write rst("username")
Response.Write "<br>"
level=level+1
GetTree(rst("gen"))
level=level-1
rst.movenext
wend
|
|
<Added>
i changed this line "GetTree(rst1("agentcode"))"
to "GetTree(rst1("gen"))"
<Added>
well, this shows all the rows...but in one column...
how can i make this structure?
[QUOTE]
A
| |
B C
/\
D E
[/QUOTE]
|
|
|
|
|
|
|
// |