当前位置:Gxlcms > PHP教程 > php获取栏目的所有子级和孙级栏目的ID号的代码

php获取栏目的所有子级和孙级栏目的ID号的代码

时间:2021-07-01 10:21:17 帮助过:13人阅读

  1. /***

  2. @ 获取子栏目ID号
  3. @ bbs.it-home.org
  4. @ 2013/2/26
  5. */
  6. private function sonCategoryIds($categoryID)
  7. {
  8. //@初始化栏目数组
  9. $array[] = $categoryID;
  10. do
  11. {
  12. $ids = '';
  13. $temp = $this->mysql->select('SELECT `id` FROM `pcb_article_category` WHERE `parentID` IN (' . $categoryID . ')');
  14. foreach ($temp as $v)
  15. {
  16. $array[] = $v['id'];
  17. $ids .= ',' . $v['id'];
  18. }
  19. $ids = substr($ids, 1, strlen($ids));
  20. $categoryID = $ids;
  21. }
  22. while (!empty($temp));

  23. $ids = implode(',', $array);

  24. return $ids;
  25. }
  26. ?>

人气教程排行