php - Strange behaviour in hierarchical menu? -


the function simple:

 function showmenu( $level = 0 ) {      $sql = "select * `menus` `submenu`=".$level;      $result = mysql_query( $sql );      echo "<ul>";          while ( $node = mysql_fetch_array( $result ) ) {              echo "<li>". $node['name'];              $sql_ = "select * `menus` `submenu`=".$node['id'];              $haschild = mysql_fetch_array( mysql_query( $sql_ ) ) != null;              if ( $haschild ) {                  showmenu( $node['id'] );              }              echo "</li>";          }      echo "</ul>";   } 

but results when i'm using level 1 or on strange. example:

showmenu( 1 ); 

will return me items, except first items.

function showmenu( $level = 0 ) {      $sql = "select * `menus` `submenu`=".$level;      $result = mysql_query( $sql );      echo "<ul>";       $rows = "";         while ( $node = mysql_fetch_array( $result ) ) {              echo "<li>". $node['name'];              $sql_ = "select * `menus` `submenu`=".$node['id'];              $execute = mysql_query( $sql_ );              $rows = mysql_num_rows($execute);             if ( $rows>0 ) {                  showmenu( $node['id'] );              }              echo "</li>";          }      echo "</ul>";   } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -