Home > php教程 > php手册 > PHP无限级分类查找父层函数

PHP无限级分类查找父层函数

WBOY
Release: 2016-06-13 10:36:32
Original
1092 people have browsed it

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;

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template