classid classfid classname classcount
1 0 中国 0
2 1 浙江 0
3 1 江苏 0
4 2 杭州 0
5 4 西湖区 0
若
findfather(4,0) 显示 => 杭州
findfather(4,1) 显示 => 浙江
findfather(4,2) 显示 => 中国
findfather(4,3) 显示 => 中国 -> 浙江 -> 杭州
代码如下:
// ========== findfather函数 start ==========
// 功能:无限级分类之找出父层的相关数据
// 参数:$classid,当前子层的编号
// $type,0找自己 1找父亲 2找祖先 3找家谱
// 字段:classid主键,自生成 classfid父编号
// classname分类名称 classcount分类统计
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 中国 0 2 1 浙江 0 3 1 江苏 0 4 2 杭州 0 5 4 西湖区 0 若 findfather(4,0) 显示 = 杭州 findfather(4,1) 显示 = 浙江 findfa...