简体   繁体   English

PHP MySQL类别树父级ID

[英]PHP MySQL Category Tree Parent Level ID

I'm creating a multi-level category with PHP/MySQL. 我正在使用PHP / MySQL创建一个多层次的类别。 I've listing my category items via ajax, but I can't get top levels by ID. 我已经通过ajax列出了我的类别项目,但是我无法通过ID获得最高级别的信息。

MySQL Table MySQL表

ID   upCID   category

1      0     Electronics
2      1     Computers
3      1     Camera & Photo
5      2     Laptops
6      2     Desktop
7      6     Keyboard & Mouse
8      6     Processors
9      6     Memory
10     6     Storage
11     8     Fans & Cooling
12     8     Thermal Compounds

Listing: 清单:

Electronics > Computers > Desktop > Processors > Thermal Compounds 电子产品>计算机>台式机>处理器>导热化合物

I want to call my top-level IDs like; 我想将我的顶级ID称为;

Thermal Compounds root level is " Electronics " 导热化合物的根级是“ 电子产品

or 要么

Thermal Compounds 3th top-level is " Desktop " 导热化合物 3顶层是“ 桌面

Normally queries easily calling my top categories but I can't get specific levels by ajax. 通常,查询很容易调用我的顶级类别,但是我无法通过Ajax获得特定级别。

使用PL SQL时可能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM