title: How to build unlimited level of menu through PHP and mysql
body: <p>Well, to build my menu my menu I use a db similar structure like this </p>
  
  <pre>
    2  Services                  0
    3  Photo Gallery             0
    4  Home                      0
    5  Feedback                  0
    6  FAQs                      0
    7  News & Events             0
    8  Testimonials              0
   81  FACN                      0
   83  Organisation Structure   81
   84  Constitution             81
   85  Council                  81
   86  IFAWPCA                  81
   87  Services                 81
   88  Publications             81
  </pre>
  
  <p>To assign another submenu for existing submenu I simply assign its parent's id as its value of parent field.
  parent 0 means top menu</p>
  
  <p>now there is not problem while creating submenu inside another submenu</p>
  
  <p>now this is way I fetch the submenu for the top menu</p>
  
  <pre><code>&lt;ul class="topmenu"&gt;
      &lt;? $list = $obj -&gt; childmenu($parentid); 
          //this list contains the array of submenu under $parendid
          foreach($list as $menu) {
              extract($menu);
              echo '&lt;li&gt;&lt;a href="#"&gt;'.$name.'&lt;/a&gt;&lt;/li&gt;';
          }
      ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>What I want to do is. </p>
  
  <p>I want to check if a new menu has other child menu</p>
  
  <p>and I want to keep on checking until it searches every child menu that is available</p>
  
  <p>and I want to display its child menu inside its particular list item like this</p>
  
  <pre><code>&lt;ul&gt;       
         &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;
          &lt;ul class="submenu"&gt;
             ........ &lt;!-- Its sub menu --&gt;
             &lt;/ul&gt;
         &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>