PHP + MySQL implementation of unlimited classification topic method, _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.