PHP Infinite column class read implementation code _php tutorial

Source: Internet
Author: User
Realize infinite Pole column classification idea: Get the self-increment ID (that is, the parent ID) and then get the child ID (that is, the UID sub-ID) data to the database as follows
Id:1 uid:0 I am the column 1
Id:2 uid:1 I am the column 2
Id:3 Uid:1 I'm a subclass of column 1

Show Results:
I am the column 1
I'm a subclass of column 1.
I am the column 2

Here is the PHP code

Copy the Code code 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 (equals 0 is the parent column)
$categoryul = anchor ("home/content/". $v->id, $v->category_name);
echo "

      ". $categoryul."
";
$LISTX = $this->listx->list_id ($v->id);//The specified sub-column is displayed according to the parent ID
foreach ($listx as $vid) {

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

    http://www.bkjia.com/PHPjc/825289.html www.bkjia.com true http://www.bkjia.com/PHPjc/825289.html techarticle realize infinite Pole column classification idea: Get the self-increment ID (that is, the parent ID) and then get the child ID (that is, the UID sub-ID) data to the database as follows Id:1 uid:0 I am the column 1 id:2 uid:1 I am the column ...

  • Related Article

    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.