[原创]递归应用-遍历所有下层分类

    技术2022-05-11  168

    /*  递归应用  */  function FindChild($parent) {   $currList = "";   $childList = "";   $result = mysql_query("SELECT id FROM 表名 WHERE parent=" . $parent);   while($rs = mysql_fetch_array($result))   {    $currList .= ($currList == "" ? "" : ",") . $rs["id"];    //取得当前$rs["id"]的所有孩子id列表    $tmpList = FindChild($rs["id"]);    if($tmpList != "") {     $childList .= ($childList == "" ? "" : ",") . $tmpList;    }   }      return $currList . ($childList != "" ? "," : "") . $childList;  }

    最新回复(0)