PHP unlimited classification query parent layer function _ PHP Tutorial

Source: Internet
Author: User
PHP unlimited class query parent layer function. ClassIDclassFIDclassNameclassCount10 China 021 Zhejiang 031 Jiangsu 042 Hangzhou 054 Xihu District 0 if findFather () show Hangzhou findFather () show Zhejiang findFa classFID className classCount
1 0 China 0
2 1 Zhejiang 0
3 1 Jiangsu 0
4 2 Hangzhou 0
5 4 Xihu District 0

If

FindFather (4, 0) display => Hangzhou

FindFather (4, 1) display => Zhejiang

FindFather (4, 2) display => China

FindFather () display => China-> Zhejiang-> Hangzhou

The code is as follows:

// =========== FindFather function START ==============
// Function: unlimitedly classify to find relevant data of the parent layer
// Parameter: $ classID, ID of the current child layer
// $ Type, 0 find yourself 1 Find Father 2 find ancestor 3 find Genealogy
// Field: primary key of the classID, which is the parent ID of the automatically generated classFID.
// ClassName category name classCount category Statistics
Function findFather ($ classID, $ type)
{
Global $ db, $ flist, $ forefather;
Define ("_ STR_CUT", "-> ");

$ Db-> query ("set names utf8 ");
$ SQL = select * from tbl_name where classID = ". $ classID .";
$ Result = $ db-> query ($ SQL );
$ RecordCount = $ result-> num_rows;

Http://www.bkjia.com/PHPjc/486519.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486519.htmlTechArticleclassID classFID className classCount 1 0 China 0 2 1 Zhejiang 0 3 1 Jiangsu 0 4 2 Hangzhou 0 5 4 Xihu District 0 if findFather () show = Hangzhou findFather) show = Zhejiang findFa...

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.