PHP + MySQL implements the unlimited classification topic method ,. The following describes how to implement the unlimited classification topic in PHP + MySQL. For your reference, I would like to share with you the following details: a very simple PHP + MySQL method for implementing the unlimited classification topic,
This article describes how to implement the unlimited classification topic in PHP + MySQL. We will share this with you for your reference. The details are as follows:
A simple, clear, and simple unlimited classification example with indentation. you only need to query the data table once and recursively traverse the result set, to enable the column indent display in php, refer.
$sql = 'select * from cat order by cat_id desc';$list = $db->getAll($sql);$list = getLevelCat($list);function getLevelCat($catlist, $parent_id='0', $html=' ', $level='0'){ $arr = array(); foreach($catlist as $val){ if($val['parent_id']==$parent_id){ $val['html'] = str_repeat($html,$level); $val['level'] = $level; $arr[] = $val; $arr = array_merge($arr, getLevelCat($catlist, $val['cat_id'], $html, $level+1)); } } return $arr;}
Implementation:
Just a few lines of code, clear and easy to use.
I hope this article will help you with PHP programming.
Articles you may be interested in:
- Php + mysql for unlimited classification
- Jquery + Ajax + PHP + MySQL implement category list management (bottom)
- Jquery + Ajax + PHP + MySQL implement category list management (on)
- PHP + Mysql unlimited classification methods
- Php + mysql implement unlimited classification instance details
- Php + mysql database implementation of unlimited classification
- Example of two methods for designing a PHP + Mysql tree structure (unlimited classification) database
- Php + mysql unlimited classification instances without recursion (non-recursion)
- Php + mysql implement unlimited classification | tree-based display of classification relationships
Examples: This article describes how to implement the unlimited classification topic in PHP + MySQL. I will share it with you for your reference. The details are as follows: a very simple...