Home > Backend Development > PHP Tutorial > Php implementation code for unlimited column classification reading_PHP tutorial

Php implementation code for unlimited column classification reading_PHP tutorial

WBOY
Release: 2016-07-13 10:24:55
Original
818 people have browsed it

The idea of ​​implementing Infinitus column classification: Get the self-increasing ID (that is, the parent ID) and then get the child ID (that is, the uid child ID) from the database. The data is 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 subcategory of column 1

Display results:                                                                                        Is a subcategory of Column 1
I am Column 2                                                
The following is the Php code

Copy code

The code is as follows: $query = $this->db-> ;query("SELECT * FROM category");
$list = $query->result();
foreach($list as $v){
if($v->category_id = = 0){//Get the parent column (anything equal to 0 is the parent column)
$categoryul = anchor("home/content/".$v->id,$v->category_name);
echo "
    ".$categoryul."
";
$listx = $this->Listx->list_id($v->id);//According to the parent id displays the specified sub-column
foreach($listx as $vid){

$category = anchor("home/content/".$vid->id,$vid ->category_name );
echo "
  • ".$category."
  • ";
    }
    }
    }
    ?>



    http://www.bkjia.com/PHPjc/825289.html

    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825289.htmlTechArticle Ideas for implementing Infinitus column classification: Get the self-increasing ID (that is, the parent ID) and then get the child ID from the database (That is, uid sub-id) The data is as follows id:1 uid:0 I am column 1 id:2 uid:1 I am column...
    Related labels:
    php
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template