无限级分类的处理我用 树 搞,
数据库中搞个分类表table_type的主要字段是  
   type_id(类序号)     type_upid(父类序号)       type_name(类名)
写个树类class Tree   //(这个Tree类不是我写的,网上搞来的)
{    var $data    = array();   
    var $child    = array(-1=>array());   
    var $layer    = array(-1=>-1); 
    var $parent    = array();
    function Tree ($value)
    {
        $this->setNode(0, -1, $value);
    } // end func
    function setNode ($id, $parent, $value)
    {
        $parent = $parent?$parent:0;        $this->data[$id]            = $value;
        $this->child[$id]            = array();
        $this->child[$parent][]        = $id;
        $this->parent[$id]            = $parent;        if (!isset($this->layer[$parent]))
        {
            $this->layer[$id] = 0;
        }
        else
        {
            $this->layer[$id] = $this->layer[$parent] + 1;
        }
    }     function getList (&$tree, $root= 0)
    {
        foreach ($this->child[$root] as $key=>$id)
        {
            $tree[] = $id;            if ($this->child[$id]) $this->getList($tree, $id);
        }
    } // end func
    function getValue ($id)
    {
        return $this->data[$id];
    } // end func
    function getLayer ($id, $space = false)
    {
        return $space?str_repeat($space, $this->layer[$id]):$this->layer[$id];
    } // end func
    function getParent ($id)
    {
        return $this->parent[$id];
    } // end func
        function getParents ($id)
    {
        while ($this->parent[$id] != -1)
        {
            $id = $parent[$this->layer[$id]] = $this->parent[$id];
        }        ksort($parent);
        reset($parent);        return $parent;
    } // end func
        function getChild ($id)
    {
        return $this->child[$id];
    } // end func        function getChilds ($id = 0)
    {
        $child = array($id);
        $this->getList($child, $id);        return $child;
    } // end func
} // end class$query="select type_id,type_upid from table_type ";
$result=$db->query($query);$Tree = new Tree();
while($r=$db->fetch_array($result))
{
$Tree->setNode($r[type_id], $r[type_upid], $r[type_name]);
}

解决方案 »

  1.   

    http://www.daima.com.cn/Info/130/Info38920/
      

  2.   

    to  Magic_kui_asd(莫一兮): 研究一下你的类
    to  olover(帅的被罚款): 这篇文章一进看过,收获较少
    to  olover(帅的被罚款): 同上谢谢三位!
      

  3.   

    对于第二个问题,你可以到这里去看看,会对你有帮助的:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebmail.asp
      

  4.   

    一直都很关注的问题,关注一下.好像用GD2做关透明水印,在WINDOWS下做的很完美,可是一样的代码到了LINUX下,水印居然变黑了(水印透明度越低,就越黑),你们的是这样吗?
      

  5.   

    3. 推荐使用GD库的把图片缩小的代码,当然,原始图片可能是gif/jpg/bmp/png中的一种,大小不定,能够缩小到指定的大小,比如23x23之类的,输出的格式可以支持多种,比如gif/jpg/png。偶然已经发布了很好的程序了,为什么不用呢?
    bmp格式图片不是网页图片,不应该在列表中!
      

  6.   

    呵呵,问题三:
     <? 
    //从源文件取出图象,设定成指定大小,并输出到目的文件 
    // 源文件格式:gif,jpg,jpe,jpeg,png 
    // 目的文件格式:jpg 
    // 参数说明: 
    // $srcFile 源文件 
    // $dstFile 目标文件 
    // $dstW 目标图象宽度 
    // $dstH 目标图象高度 function makethumb($srcFile,$dstFile,$dstW,$dstH) { 
    $data = GetImageSize($srcFile,&$info); 
    switch ($data[2]) { 
    case 1: 
    $im = @ImageCreateFromGIF($srcFile); 
    break; 
    case 2: 
    $im = @imagecreatefromjpeg($srcFile); 
    break; 
    case 3: 
    $im = @ImageCreateFromPNG($srcFile); 
    break; 

    $srcW=ImageSX($im); 
    $srcH=ImageSY($im); 
    $dstX=0; 
    $dstY=0; 
    if ($srcW*$dstH>$srcH*$dstW) { $fdstH=round($srcH*$dstW/$srcW); $dstY=floor(($dstH-$fdstH)/2); $fdstW=$dstW; } 
    else { $fdstW=round($srcW*$dstH/$srcH); $dstX=floor(($dstW-$fdstW)/2); $fdstH=$dstH; } 
    $ni=ImageCreate($dstW,$dstH); 
    $dstX=($dstX<0)?0:$dstX; 
    $dstY=($dstX<0)?0:$dstY; 
    $dstX=($dstX>($dstW/2))?floor($dstW/2):$dstX; 
    $dstY=($dstY>($dstH/2))?floor($dstH/s):$dstY; 
    $black = ImageColorAllocate($ni, 0,0,0);//填充的背景色你可以重新指定,我用的是黑色 
    imagefilledrectangle($ni,0,0,$dstW,$dstH,$black); 
    ImageCopyResized($ni,$im,$dstX,$dstY,0,0,$fdstW,$fdstH,$srcW,$srcH); 
    ImageJpeg($ni,$dstFile);//如果你要把图片直接输出到浏览器, 
    //那么把第二个参数去掉,并用header()函数指定mine类型先 
    imagedestroy($im); 
    imagedestroy($ni); 
    }
    //测试:
    makethumb("cs.jpg","cs3.png",80,80,"png"); 
    ?> 
      

  7.   

    问题五:
    客户端:
    $xml = "<dictworld></dictworld>";
    $fp = fsockopen("localhost", 80) or die("can't connect localhost");
    fputs($fp, "POST /xml.php HTTP/1.0\n");
    fputs($fp, "Content-type: text/xml\n");
    fputs($fp, "Content-length: ".strlen($xml)."\n\n");
    fputs($fp, $xml);while (!feof($fp))
    {
        $response .= fgets($fp);
    }服务器端:
    $fp = fopen("php://input", "r");
    while (!feof($fp))
    {
       $xml .= fgets($fp);
    }
      

  8.   

    to Meteorlet(www.dictworld.com):难道RPC的客户端和服务器端都必须由PHP本身来实现?
      

  9.   

    1.这个东西应该不难吧?主要就是session的操作了.
    2.我目前用的,还可以。
       http://www.icebergweb.com/download/class.rar
    3.自己写的类感觉有些冗长,就不贴了。
    4.和第二个smtp类同在class.rar包中. 采用的是插值排序法,理论上是无限的,
      多说一句,无限分类其实我们一般使用只有几级而已,只要能到满足要求是不是无限都无所谓了。
      以前也写过一个使用字符串排序的,不过级数有限,现在不使用了。
    5.XML_RPC和SOAP同是基于HTTP的二种XML应用协议,说白了,就是客户端和服务器端使用规定格式的XML数据进行通信,就像明白了HTTP协议后,我们可以使用PHP来模拟浏览器来POST数据一样,这些东西是基于HTTP的,使用SOCKET来操作完全可以,只要保证数据格式的正确性即可。
      

  10.   

    感谢  ice_berg16(寻梦的稻草人) !
      

  11.   

    //获取导航条,根据classID 获取导行
    function GetNavi(&$navi,$paramClassID,$paramDb,$endClassID=0)
    {

    $classID = $paramClassID;
    $db = $paramDb;
    $query = "select * from tbl_class where classID=$classID";//取得本层信息 
    $db->ExecQuery($query);
    $numRows = $db->NumRows();
    if($numRows)//本层记录存在
    {
    $classInfo = $db->FetchArray();//本层信息存放数组
    //本层信息导行
    if($navi == "")
    {
    $navi = "<a href=classManage.php?classID=".$classInfo['classID']."><font color=#cccccc>".$classInfo['className']."</font></a>";
    }
    else
    {
    $navi = "<a href=classManage.php?classID=".$classInfo['classID']."><font color=#cccccc>".$classInfo['className']."</font></a>>>".$navi;
    }

    //递归上一层
    if($classInfo['classPID'] != $endClassID)
    {
    GetNavi($navi,$classInfo['classPID'],$db,$endClassID);
    }
    else//将根目录连接在上面
    {
    $navi = "<a href=classManage.php?classID=0><font color=#cccccc>首页</font></a>>>".$navi;
    }
    }
    return $navi;
    }
    //前台图片自适应大小
    function ShowImg($img,$refWidth,$refHeight) 
    {

    $size = getimagesize($img);
    $width = $size[0];
    $height = $size[1];
    if($width > $height)
    {
    $n = $width/$refWidth;
    $width = $refWidth;
    $height = $height/$n;
    }
    else
    {
    $n = $height/$refHeight;
    $width = $width/$n;
    $height = $refHeight;
    }
    $tmpImg = "<img src=".$img." border=0 width=".$width." height=".$height.">";
    return $tmpImg;
    } //根据当前ID ,其下的所以叶子结点ID
    function GetAllLeafID(& $allClassIDs,$paramClassID,$paramDb)
    {

    $classID = $paramClassID;
    $db = $paramDb;
    $query = "select classID from tbl_class where classPID=".$classID;
    $db->ExecQuery($query);
    $numRows = $db->NumRows();
    if($numRows == 0)
    {
    if($allClassIDs == "")
    {
    $allClassIDs = $classID;
    }
    else
    {
    $allClassIDs = $allClassIDs.",".$classID;
    }
    }
    else
    {
    while($tmpInfo = $db->FetchArray())
    {
    if(!empty($tmpInfo[0]))
    {
    GetAllLeafID($allClassIDs,$tmpInfo[0],$db);
    }
    }
    }
    //echo $allClassIDs;
    return $allClassIDs;
    }
    //