PHP获取栏目的所有子级和孙级栏目的ID号示例


//@获取子栏目ID号
private function sonCategoryIds($categoryID)
{
//@初始化栏目数组
$array[] = $categoryID;

do
{
$ids = '';
$temp = $this->mysql->select('SELECT `id` FROM `pcb_article_category` WHERE `parentID` IN (' . $categoryID . ')');
foreach ($temp as $v)
{
$array[] = $v['id'];
$ids .= ',' . $v['id'];
}
$ids = substr($ids, 1, strlen($ids));
$categoryID = $ids;
}
while (!empty($temp));

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

return $ids;
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/69abf301c10243084460f8c06dbe9867.html