Home >Backend Development >PHP Tutorial >PHP unlimited classification (with database) (1/2)_PHP tutorial

PHP unlimited classification (with database) (1/2)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:57:571254browse

This is a PHP infinite-level classification code written using recursion. It is a tree-type infinite-level classification example. The infinity is achieved by using recursion. There are also more advanced writing methods, binary trees to achieve infinite classification. .

php tutorial unlimited classification (with database tutorial)
/*
This is a PHP infinite-level classification code written using recursion. It is a tree-type infinite-level classification example. The infinity is achieved by using recursion. There are also more advanced writing methods, binary trees to achieve infinite classification.
*/
?>








电视树状目录


 $globals["id"] =1;
 $jibie=1;
 $sql="select * from tvmenu where bid=0";
 $result=mysql教程_query($sql,$conn);
 
 if(mysql_num_rows($result)>0)
 treemenu($conn,$result,$jibie,$id);
 
 function treemenu($conn,$result,$jibie)  //进入函数循环
 {
 $numrows=mysql_num_rows($result);
 echo "";
 for($rows=0;$rows<$numrows;$rows++)
 {
 $menu=mysql_fetch_array($result);
 $sql="select * from tvmenu where bid=$menu[id]";
 $result_sub=mysql_query($sql,$conn);
 echo "";
  //如果该菜单项目有子菜单,则添加javascript onclick语句
  if(mysql_num_rows($result_sub)>0)
  {
  echo "";
  echo "";
  echo "";
  if(mysql_num_rows($result_sub)>0)
  {
  echo "";
  echo "";
  echo "";
  }
  //显示下一菜单
  }
  echo "
";
}
?>







 
   
 
 
   
   
 
 
   
   
 
 
   
 
 
添加栏目
栏目名称:
所属分类:
   

1 2

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632040.htmlTechArticle这是一款利用递归写的php无限级分类代码,是一款树型的无限级分类实例,一的无限都是利用递归来实现的,也有更高级的写法,二叉树来...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP blog website development example tutorial (1/8)_PHP tutorialNext article:PHP blog website development example tutorial (1/8)_PHP tutorial

Related articles

See more