[Need] Binary Tree by PHP & MySQL

Started on the old forum in September 2013 · view the original in the archive · old links redirect here

5 replies · 2,078 views · started 13 years ago · 1 min read

4 participants
asifnayem Developer · 119 posts #1

Hi,

I need a help regarding binary tree. My db table structure is: ID, userid, position, referid.

Now I want to show this like binary tree:

                      1
          ------------------
         |                    |
         2                    3
         |                        |
   ---------            -----------
  |          |          |              |
  4         5         6              7

Can anyone help me to solve this?

something else Fellow · 2,296 posts #2

Maybe some more info is required to answer this question as its not making much sense for what you need help with

asifnayem Developer · 119 posts #3

something else wrote: Maybe some more info is required to answer this question as its not making much sense for what you need help with

Well, I'm creating a site where I need to have a binary tree for downline. Like if I refer someone to the site, he/she'll be my downline and will be putted under my tree (left/right). I've searched over the net but hardly find any solution. The hierarchy will looks like this image below:

Attachments: Untitled.png
shushant Developer · 207 posts #4

i think binary tree concept makes no sense in php. it won't speed up array indexing. if you are worry about array performance then consider using PHP: SplFixedArray - Manual

and binary tree is just a headache for example if sub tree 3 somehow break child tree (6, 7) will easily not accessible (but can be fixed with small math)

for more info refer to Binary tree - Wikipedia, the free encyclopedia

asifnayem Developer · 119 posts #5

Hi, @something else can you please help?

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close