title: Show Category table with parent categories
body: <p>Below is my table structure:</p>
  
  <p><strong>Menu Table</strong></p>
  
  <pre><code>id   title  position
  --------------------    
  1    Test    home
  2    Test2   home   
  </code></pre>
  
  <p><strong>Category</strong></p>
  
  <pre><code>cid   name   parent  parent_menu
  --------------------------------
   1    ABC      0         1
   2    DEF      0         2
   3    GHI      1         0
   4    JKL      2         0
  </code></pre>
  
  <p><strong>Category Description</strong></p>
  
  <pre><code>id    cat_id    catdesc   slug
  -------------------------------
   1      1       ABC_DESC   abc
   2      2       DEF_DESC   def
   3      3       GHI_DESC   ghi
   4      4       JKL_DESC   jkl    
  </code></pre>
  
  <ul>
  <li><code>Menu table</code> handles the menu title an position.</li>
  <li><code>Category table</code> handles category name and other parameters. (if parent=0 then it means that this is main category and so on..)</li>
  <li><code>Category Description table</code> handles the description, slug and other parameters.</li>
  </ul>
  
  <p>Now i want to display data like as below</p>
  
  <pre><code> Name      Description      Edit         Delete        /*table headings*/
  -------------------------------------------------------
    Menu Title: (Test)    Main Category Name: (ABC)      
   ------------------------------------------------------
   GHI       GHI_DESC      edit_icon       delete_icon
   ______________________________________________________
    Menu Title: (Test2)    Main Category Name: (DEF)
   ------------------------------------------------------
    JKL       JKL_DESC      edit_icon       delete_icon
  </code></pre>
  
  <p>I tried to use JOINS and manipulate data in PHP but no luck.</p>
  
  <pre><code>SELECT * FROM `category` t1 LEFT JOIN `category_description` t2 ON t1.cid = t2.cat_id WHERE 1
  </code></pre>
  
  <p>Then in PHP i tried like as below</p>
  
  <pre><code>&lt;?php $i = 1; foreach($subcat as $sub) { ?&gt;
       &lt;?php if($sub-&gt;parent == 0) { ?&gt;
         &lt;tr&gt;&lt;td&gt;&lt;?php echo $sub-&gt;name ?&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;?php } ?&gt;
       &lt;?php if($sub-&gt;parent != 0) { ?&gt;
         &lt;tr&gt;&lt;td&gt;&lt;?php echo $sub-&gt;name ?&gt;&lt;/td&gt;&lt;td&gt;&lt;?php echo $sub-&gt;catdesc ?&gt;&lt;/td&gt;
         &lt;td&gt;Edit&lt;/td&gt;&lt;td&gt;Delete&lt;/td&gt;&lt;/tr&gt;
       &lt;?php } ?&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>And above prints table like as below:</p>
  
  <pre><code>Main Category Name: ABC
  Main Category Name: DEF
  ------
  GHI  GHI_DESC
  JKl  JKL_DESC
  </code></pre>
  
  <p>Please suggest how to print as desired. </p>