Home  >  Article  >  Backend Development  >  PHP infinite classification to find parent layer function_PHP tutorial

PHP infinite classification to find parent layer function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:38:061097browse

classID classFID className classCount
1 1 0 0 China China 0
2 1 1 Zhejiang 0
3 1 1 Jiangsu 0
4 2 2 Hangzhou 0
5 4 4 West Lake District 0

If

findFather(4,0) show => Hangzhou

findFather(4,1) shows => Zhejiang

findFather(4,2) show => China

findFather(4,3) shows => China -> Zhejiang -> Hangzhou

The code is as follows:

 // ========== findFather function START ==========
// Function: Unlimited classification to find relevant data of the parent layer
// Parameter: $classID, the number of the current sub-layer
// $type,0 Find yourself 1 Find your father 2 Find your ancestors 3 Find your family tree
// Field: classID primary key, self-generated classFID parent number
// className category name classCount category statistics

 function findFather($classID,$type )
{
 
global $db,$flist,$forefather;
  >
" -> ");    $db->query("set names utf8
"
);
" .$classID."
; $result = $db-> query($sql);
 
$recordCount = $result-> num_rows;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486519.htmlTechArticleclassID classFID className classCount 1 0 China0 2 1 Zhejiang0 3 1 Jiangsu0 4 2 Hangzhou0 5 4 West Lake District 0 If findFather(4,0) displays = Hangzhou findFather(4,1) displays = Zhejiang findFa...
Statement:
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