Let's see how this code doesn't get the root classification id!. Tokyu
/*
* Get root classification based on subclass ID
*/
function Get_root_class ($classId) {
Global $db, $lot _array;
$class = $db->fetch_first ("Select PID, name from New_infor_class WHERE id = $classId");
if ($class [' pid ']! = 0) {
Get_root_class ($class [' pid ']);
} else {
return $class [' name '];
}
}
Classification is set according to the infinite classification, so return is $CLASSID classification name, really do not understand! Who's the big Brother to help me!
------Solution--------------------
Okay, just a test environment.
SQL Code
Structure of the----table ' tree '--create table IF not EXISTS ' tree ' ( ' id ' int (one) not NULL auto_increment, ' pid ' int (one) ' DEFAULT NULL, ' name ' varchar (TEN) default NULL, PRIMARY KEY (' id ')) engine=myisam default Charset=latin1 auto_ increment=5;----Dump the data in the table ' tree '--insert into ' tree ' (' id ', ' pid ', ' name ') of VALUES (1, 0, ' a '), (2, 1, ' B '), (3, 2, ' C '), (4, 3 , ' d ');