title: how to php mysql draw a tree structure
body: <p>I have the below MySQL records, so need to draw a tree structure in PHP by using the below MySQL data, here NULL value represents the primary parent node,</p>
  
  <blockquote>
    <p><code>
    +----------------+----------------+
    | id             | parent_id      |
    +----------------+----------------+
    | 1              |            NULL|
    | 2              |            1   |
    | 3              |            1   |
    | 4              |            2   |
    | 5              |            3   |
    | 6              |            2   |
    +----------------+----------------+</code></p>
  </blockquote>
  
  <p>the output should be a below format</p>
  
  <blockquote>
  <pre><code>             1
             /   \ 
           2      3
          / \    /
         4   6  5     
  </code></pre>
  </blockquote>
  
  <p>please help me.</p>
  
  <p>try to <a href="https://www.daniweb.com/programming/web-development/threads/231905/binary-tree-using-php-mysql#post1027437" rel="nofollow noreferrer">https://www.daniweb.com/programming/web-development/threads/231905/binary-tree-using-php-mysql#post1027437</a></p>
  
  <p>not working</p>