title: How to Print Binary Tree from the given Database Structure using PHP?
body: <p>I have a MySQL database in this format :</p>
  
  <p>table name : btree_mst
  fields : id, parent_id, left_node_id, right_node_id, user_name</p>
  
  <p>Now what I have to do is print it in the Un-ordered list format like below</p>
  
  <ul>
     <li>Root Node
         <ul>
              <li>Node A
                  <ul>
                       <li>Node A Left</li>
                       <li>Node A Right</li>
                  </ul> 
              </li>
              <li>Node B
                  <ul>
                       <li>Node B Left</li>
                       <li>Node B Right</li>
                  </ul>
              </li>
         </ul>
     </li>
  </ul>
  
  <p>I tried to make a recursive function for that but didn't work as expected. 
  Any suggestions ?</p>
  
  <p>Here is the Code I made, <a href="http://pastebin.com/X15qAKaA" rel="nofollow">http://pastebin.com/X15qAKaA</a> 
  The only bug in this code is, it is printing UL every time. It should print only when the Level is changed.</p>
  
  <p>Thanks in advance.</p>