1024programmer Blog php finds out according to the parent id, PHP infinite classification finds the parent function_weixin_39653442’s blog

php finds out according to the parent id, PHP infinite classification finds the parent function_weixin_39653442’s blog

PHP unlimited classification to find the parent layer function

classID classFID className classCount

1 0 0 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) shows => Hangzhou

findFather(4,1) shows => Zhejiang

findFather(4,2) shows => China

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

The code is as follows:

54965d72aab5bd8c0c03acaf4aa9dd2b.gif//========= = findFather function START ===========

54965D72Aab5bd8c8c 0C03ACAF4AA9dd2b.gif // Function: Finding the father of unlimited classification Layer related data

54965d72aab5bd8c0c03acaf4aa9dd2b.gif // Parameters: $classID, current class layers number

54965d72aab5bd8c0c03acaf4aa9dd2b.gif // $type, 0 looking for self 1 looking for father 2 Find ancestors 3 Find genealogy

54965d72aab5bd8c0c03acaf4aa9dd2b.gif // Field: classID primary key, since generate classFID parent number

54965d72aab5bd8c0c03acaf4aa9dd2b.gif // className category name classCount category statistics 54965d72aab5bd8c0c03acaf4aa9dd2b.giffunctionfindFather($classID,$type)

54965d72aab5bd8c0c03acaf4aa9dd2b.gif {

54965d72aab5bd8c0c03acaf4aa9dd2b.gifglobal$db,$flist,$forefa ther;

54965d72aab5bd8c0c03acaf4aa9dd2b.gifdefine(“_STR_CUT”, ” ->”) ;

54965d72aab5bd8c0c03acaf4aa9dd2b.gif

54965d72aab5bd8c0c03acaf4aa9dd2b.gif$db->query(“set names ut f8” );

54965d72aab5bd8c0c03acaf4aa9dd2b.gif$sql=select * from tbl_name where classID = “.$classID.”;

54965d72aab5bd8c0c03acaf4aa9dd2b.gif$result=$db->query($sql );

54965d72aab5bd8c0c03acaf4aa9dd2b.gif$recordCount=$result->num _rows;

54965d72aab5bd8c0c03acaf4aa9dd2b.gif

/phprm/27846.htmlwww.phpzy.comtrue/phprm/27846.htmlTechArticlePHP Unlimited classification search parent function classID classFID className classCount 1 0 China 0 2 1 Zhejiang 0 3 1 Jiangsu 0 4 2 Hangzhou 0 5 4 West Lake District 0 If findFather(4,0) display = Hangzhou findFather(4,1) display = Zhejiang findFather(4,2) display = China…

Related articles

No related articles

Friends of PHP Comments

Recommended today

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/php-finds-out-according-to-the-parent-id-php-infinite-classification-finds-the-parent-function_weixin_39653442s-blog/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索