PHP Unlimited class Read the implementation code of column classification

Source: Internet
Author: User
Tags foreach php code

  below to share a PHP implementation of unlimited column category reading examples, I hope that the article will bring help to you

The idea of realizing infinite pole column classification: Get the ID (that is, the parent ID) and then get the child ID (that is, the UID child ID) to the database as follows Id:1  uid:0   I am column 1 id:2  uid:1   I am column 2 id:3  uid:1   I am a subclass of column 1   display results:                       &NBS P                          I'm column 1       &NBSP ;                                   &NB Sp      I am a subclass of column 1 I am column 2                   The following is the PHP code     Code As follows: <?php    $query = $this->db->query ("Select * from category");   $list = $query->result ();  foreach ($list as $v) { if ($v->category_id = 0) {//Get parent column (equal to 0 is parent)   $categoryul = anchor ("home/ content/". $v->id, $v->category_name);  echo "<ul>". $categoryul. " </ul> ";   $LISTX = $this->listx->list_id ($v->id);/Displays the specified sub-column  foreach ($listx as $vid) {    $category = anchor ("home/content/") based on the parent ID. $vid->id, $vid-> Category_name);  echo "<li>". $category. " </li> ";   &NBSP}    }  }?>   
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.