設置 | 登錄 | 註冊

作者共發了2篇帖子。

php遍歷子孫節點真複雜啊!!!

1樓 产品的注销 2010-12-20 13:20
2樓 产品的注销 2010-12-20 13:21

所以我把代碼備份一下:

<?php

# 獲取當前節點下的全部子孫節點
  $catalog_grandson_nodes=array();
  $cc=array($catalog_baseid);
  for ($jibie=$catalog_gread+1;true;$jibie++){
   $ki=sExplode(',',$cc);
   $sql="select 編號,所屬父類 from 貼吧分類 where 級別=".$jibie." and 所屬父類 in (".$ki.")";
   $rs=db_query($sql);
   if (db_num($rs)<1) break; # 若已到了分支末端
   $cc=array();
   while ($row=db_eof($rs)){
    $catalog_grandson_nodes[count($catalog_grandson_nodes)]=$row[0];
    $cc[count($cc)]=$row[0];
   }
  }
  $catalog_grandson_nodes_string=sExplode(",",$catalog_grandson_nodes);
  if ($catalog_grandson_nodes_string=="") $catalog_grandson_nodes_string=$catalog_baseid;

?>

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。