Home > Backend Development > PHP Tutorial > PHP code to obtain the ID numbers of all child and grandchild columns of a column

PHP code to obtain the ID numbers of all child and grandchild columns of a column

WBOY
Release: 2016-07-25 09:04:25
Original
1165 people have browsed it
  1. /***

  2. @ Get sub-column ID number
  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. ?>

复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template