title: How to make a tree view from MySQL and PHP and jquery
body: <p>i need to show a treeview of my categories , saved in my mysql database .</p>
  
  <p>Database table :</p>
  
  <blockquote>
    <p><strong>table</strong> : cats : </p>
    
    <p><strong>columns</strong>: id,name,parent
    problem is in php part :</p>
  </blockquote>
  
  <pre><code>//function to build tree menu from db table test1
  function tree_set($index)
  {
      global $menu;
      $q=mysql_query("select * from cats where parent='$index'");
      if(!mysql_num_rows($q))
          return;
      $menu .= '&lt;ul&gt;'."\n";
      while($arr=mysql_fetch_assoc($q))
      {
          $menu .= '&lt;li&gt;';
          $menu .= '&lt;span class="file"&gt;'.$arr['name'].'&lt;/span&gt;';//you can add another output there
          $menu .=tree_set("".$arr['id']."");
          $menu .= '&lt;/li&gt;'."\n";
      }
  
      $menu.= '&lt;/ul&gt;'."\n";
  return $menu;
  
  }
  
  
  
  //variable $menu must be defined before the function call
   $menu = '
   &lt;link rel="stylesheet" href="modules/Topics/includes/jquery.treeview.css" /&gt;
   &lt;script src="modules/Topics/includes/lib/jquery.cookie.js" type="text/javascript"&gt;&lt;/script&gt;
   &lt;script src="modules/Topics/includes/jquery.treeview.js" type="text/javascript"&gt;&lt;/script&gt;
   &lt;script type="text/javascript" src="modules/Topics/includes/demo/demo.js"&gt;&lt;/script&gt;
   &lt;ul id="browser" class="filetree"&gt;'."\n";
   $menu .= tree_set(0);
   $menu .= '&lt;/ul&gt;';
  echo $menu;  
  </code></pre>
  
  <p>i even asked in this forum :
  <a href="http://forums.tizag.com/showthread.php?p=60649" rel="nofollow noreferrer">http://forums.tizag.com/showthread.php?p=60649</a></p>
  
  <p><strong>problem is in php part of my codes that i mentioned . i cant show sub menus , i mean , really i dont know how to show sub menus</strong></p>
  
  <p>is there any chance of a pro php coder helping  me  here ? </p>