/*
递归应用
*/
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;
}
递归应用
*/
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;
}