<?PHP header("Content-type: text/html; charset=utf-8"); $link = mysql_connect('localhost','root','eric') or die(mysql_error()); mysql_select_db('sortclass',$link); class SortClass{ var $data = array(); var $child = array(-1=>array()); var $layer = array(-1=>-1); var $parent = array(); var $link; var $table; function SortClass($link, $table){ $this->setNode(0, -1, '顶极节点'); $this->link = $link; $this->table = $table; $node = array(); $results = mysql_query('select * from '.$this->table.'',$this->link); while($node = mysql_fetch_assoc($results)){ $this->setNode($node['cid'],$node['pid'],$node['cname']); } }
This is an implementation library for PHP infinite splitting, with two methods: recursive and non-recursive. Friends who need it can download it and use it.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
21 Jul 2016
PHP unlimited classification (tree class). Copy the code as follows: ?php //Simulate PHP unlimited classification query results return array( array( 'id'=1, 'pid'=0, 'name'='Homepage' ), array( 'id'=2, ' pid'=0, 'name'='News' ), array( 'id'=
25 Jul 2016
PHP unlimited classification father and son tracing method
15 Aug 2020
This article mainly introduces two methods to achieve unlimited classification in PHP+Mysql, and compares and analyzes the advantages and disadvantages of the two methods. Friends in need can refer to it.
21 Jul 2016
A PHP class tree (supports unlimited classification). Recently, there have been a lot of questions asked about infinite classification trees, so I was happy to write one myself. I just finished it. You can try it and see how to implement it faster and simpler. Post your tree as well.
13 Jul 2016
PHP calls the dll class library method developed in C#. PHP calls dll class library methods developed in C#. Sometimes, we need to use dll class libraries written in other languages in php, such as dlls written in C#. The method is to use the PHP new COM method to call.
12 Jul 2016
PHP MySQL method to implement unlimited classification columns. PHP MySQL's method of implementing unlimited classification columns. This article describes the method of PHP MySQL's implementation of unlimited classification columns. Share it with everyone for your reference, the details are as follows: A very simple
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images