Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 09:39:54
Original
811 people have browsed it

复制代码 代码如下:


//@获取子栏目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;
}

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!