php finds out according to the parent id, php, _ three-level classification like query finds many ids and needs to find the corresponding parent id and combine them according to the parent id. How should the data be combined according to the parent id? , phpphpStudy…
Three-level classification like query If you find many ids, you need to find the corresponding parent id and combine them according to the parent id. How should you combine the data according to the parent id? This is the obtained data parent id is parent_id Array ( [0] => Array ( [department_id] => 1 [parent_id] => 0 [department_code] => xsb1 [department_name] => Sales Department 1 [department_phone] => [department_cornet] => [department_description] => [department_sort] => 0 [is_delete] => 1 [department_status] => 1 [add_time] => 1470039207 [add_user_id] => 1 [edit_time] => 1470039207 [edit_user_id] => 1 ) [1] => Array ( [department_id] => 2 [parent_id] => 1 [department_code ] => xs1q [department_name] => Sales District 1 [department_phone] => [department_cornet] => [department_description] => [department_sort] => 0 [is_delete] => 1 [department_status] => 1 [add_time] => 1470039207 [add_user_id] => 1 [edit_time] => 1470039207 [edit_user_id] => 1 ) [2] => Array ( [department_id] => 3 [parent_id] => 2 [department_code] => xs1ks [department_name] => Sales 1 department [department_phone] => [department_cornet ] => [department_description] => [department_sort] => 0 [is_delete] => 1 [department_status ] => 1 [add_time] => 1470039207 [add_user_id] => 1 [edit_time] => 1470039207 [edit_user_id] => 1 ) [3] => Array ( [department_id] => 4 [parent_id] => 2 [department_code] =>…
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: //========= = findFather function START =========== // Function: Finding the father of unlimited classification Layer related data // Parameters: $classID, current class layers number // $type, 0 looking for self 1 looking for father 2 Find ancestors 3 Find genealogy // Field: classID primary key, since generate classFID parent number // className category name classCount category statistics functionfindFather($classID,$type) { global$db,$flist,$forefa ther; define(“_STR_CUT”, ” ->”) ; $db->query(“set names ut f8” ); $sql=select * from tbl_name where classID = “.$classID.”; $result=$db->query($sql ); $recordCount=$result->num _rows; /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…