PHP Unlimited class Read the implementation code of column classification

Source: Internet
Author: User

  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}    }  }?>   

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.