/**  BEGIN function
    *
    *   作者:偶然
    *   功能:递归出树形下拉菜单,稍加休改可以得到目录树
    *   时间:2003.7.5
    *   变量:
    *   返回:none
    *   示例:
    *
    */
    function select($fid,$num,$i,$lang_type)
    {
        global $nav;
        $num++;
        $sql="select fid,cid,c_name from category where fid='$fid'order by cid desc";
        $query=$this->query($sql);
        while($array=$this->fetch_array($query))
        {
            $i=count($nav);
            $nav[$i]["num"]=$num;
            $nav[$i]["fid"]=$array['fid'];
            $nav[$i]["navid"]=$array['cid'];
            $nav[$i]["navname"]=$array['c_name'];
            $this->select($nav[$i]["navid"],$num,$i,$lang_type);
            $i++;
        }
        Return $nav;
    }

解决方案 »

  1.   

    上面忘了把$lang_type去掉,那本来是用来标识语言的,对你来说没有什么用。
      

  2.   

    <?
    $db = new cdb();
    function  select($id)
    { $query = "select * from tablename where parentGrpId='$id'"
    $db->query($query); while($db->next_record)
    {
    $id = $db->f('gourpID');
    $query1 = "select * from tablname where parentGrpId='$id'"    
    $db->query($query1)
    }
     return $db->f('groupName');

    }
    ?>
      

  3.   

    $db=opendb("thematicmap");
    $sql="select * from mapgroup where parentGrpID=0";
    $rs_root=$db->execute($sql);
    echo "<ul>";
    for($i=1;$i<=$rs_root->recordcount();$i++)
    {
        echo "<li>Root:".$rs_root->fields['groupName'];"</li><br>";
        deep($rs_root->fields['groupID']);
        $rs_root->movenext();}
    echo "</ul>";
    //echo "<table>";function deep($p_id)
    {
        $sql="select * from mapgroup where parentGrpID=".$p_id;
        $db=opendb("thematicmap");
        $rs=$db->execute($sql);
        if ($rs->recordcount()!==0)
        {
            echo "<ul>";
            for ($j=1;$j<=$rs->recordcount();$j++)
            {
               echo "<li>".$rs->fields['groupID'].":".$rs->fields['groupName']."</li><br>";
               deep($rs->fields['groupID']);
               $rs->movenext();
            }
            echo "</ul>";
        }
        $rs->close;
    }