title: get hierarchical data from mysql
body: <p>I want to display menu from mysql database. This is what I tried so far and don't know what is the error for.
  I appreciate any help . I posted the table that I want to display and the error that I got </p>
  
  <blockquote>
    <p>Warning: mysql_fetch_assoc() expects parameter 1 to be resource,
    boolean given in C:\wamp\www\second _try\eCRA.php on line 18</p>
  </blockquote>
  
  <pre><code>&lt;?php
      function display_menu($parent, $level) {
          $query=mysql_query("SELECT n.id, n.menu_name, n.link, d.count FROM 'menu' n 
          LEFT OUTER  JOIN(SELECT parent, COUNT (*) AS count FROM 'menu' GROUP BY
          parent) d ON  n.id=d.parent  W HERE n.parent=".$parent);
          echo"&lt;ul&gt;";
  
          while($row = mysql_fetch_assoc($query)) {
              if($row['count']&gt;0) {
                  echo"&lt;li&gt;&lt;a href='" .$row['link']. "'&gt;". $row['menu_name'] ."&lt;/a&gt;";
                  display_menu($row['id'], $level + 1);
                  echo"&lt;/li&gt;";
              }//f
              elseif($row['count']==0) { 
                  echo"&lt;li&gt;&lt;a href='". $row['link'] ."'&gt;". $row['menu_name'] ."&lt;/a&gt;&lt;/li&gt;";
              }else; 
          }//w
          echo"&lt;/ul&gt;";
      }
  
      display_menu(0,2);
  ?&gt;
  </code></pre>
  
  <p><code>![error][1]</code>
  <code>![Table][2]</code></p>