ClassID 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;