php 根据父级id查出,php,
三级分类 like查询 查询到很多id 需要找到对应的父级id 并根据父级id组合 应该怎么根据父级id将数据组合在一起呢?
这是获取到的数据 父级id为parent_id
Array
(
[0] => Array
(
[department_id] => 1
[parent_id] => 0
[department_code] => xsb1
[department_name] => 销售部1
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[1] => Array
(
[department_id] => 2
[parent_id] => 1
[department_code] => xs1q
[department_name] => 销售1区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[2] => Array
(
[department_id] => 3
[parent_id] => 2
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[3] => Array
(
[department_id] => 4
[parent_id] => 2
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[4] => Array
(
[department_id] => 5
[parent_id] => 2
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[5] => Array
(
[department_id] => 6
[parent_id] => 2
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[6] => Array
(
[department_id] => 7
[parent_id] => 1
[department_code] => xs2q
[department_name] => 销售2区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[7] => Array
(
[department_id] => 8
[parent_id] => 7
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[8] => Array
(
[department_id] => 9
[parent_id] => 7
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[9] => Array
(
[department_id] => 10
[parent_id] => 7
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[10] => Array
(
[department_id] => 11
[parent_id] => 7
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[11] => Array
(
[department_id] => 12
[parent_id] => 0
[department_code] => xsb2
[department_name] => 销售部2
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[12] => Array
(
[department_id] => 13
[parent_id] => 12
[department_code] => xs3q
[department_name] => 销售3区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[13] => Array
(
[department_id] => 14
[parent_id] => 13
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[14] => Array
(
[department_id] => 15
[parent_id] => 13
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[15] => Array
(
[department_id] => 16
[parent_id] => 13
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[16] => Array
(
[department_id] => 17
[parent_id] => 13
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[17] => Array
(
[department_id] => 18
[parent_id] => 12
[department_code] => xs4q
[department_name] => 销售4区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[18] => Array
(
[department_id] => 19
[parent_id] => 18
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[19] => Array
(
[department_id] => 20
[parent_id] => 18
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039208
[add_user_id] => 1
[edit_time] => 1470039208
[edit_user_id] => 1
)
[20] => Array
(
[department_id] => 21
[parent_id] => 18
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039208
[add_user_id] => 1
[edit_time] => 1470039208
[edit_user_id] => 1
)
[21] => Array
(
[department_id] => 22
[parent_id] => 18
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039208
[add_user_id] => 1
[edit_time] => 1470039208
[edit_user_id] => 1
)
)
这个还是三级分类有可能搜到的是最后一级 那还要找俩级 怎么去合并啊
相关阅读:
@connect是什么操作?
安卓机微信打开HTML5会卡顿
jquery 多个DIV展开折叠
php重载与重写的区别?重载与其他语言(如java)有何差异?
TP框架的这句话哪里不对?
sysctl,launchctl,ulimit三者的关系和异同
关于viewpager的滑动
Android下大部分国产浏览器不响应html5的退出全屏的api,这个如何解决?
类似很久以前文字冒险游戏的指令系统
关于oracle 10g重复插入数据的问题
Django中调用可执行文件,如何添加路径
SQLAlchemy 模型定义中 __init__() 的用途是什么?
IDEA怎么去掉代码块之间的竖线
是否应该对“评论”字段也增设“投票” 机制?
ionic中的modal中如何实现导航视图
amaze ui touch怎么配置环境啊!!!!
如何使用node+jquery ajax实现图片上传?
关于UIPageViewController
请教一个 d2d 的内存释放问题
Hexo deploy报错: TypeError : undefined is not a function
php 根据父级id查出,php,
三级分类 like查询 查询到很多id 需要找到对应的父级id 并根据父级id组合 应该怎么根据父级id将数据组合在一起呢?
这是获取到的数据 父级id为parent_id
Array
(
[0] => Array
(
[department_id] => 1
[parent_id] => 0
[department_code] => xsb1
[department_name] => 销售部1
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[1] => Array
(
[department_id] => 2
[parent_id] => 1
[department_code] => xs1q
[department_name] => 销售1区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[2] => Array
(
[department_id] => 3
[parent_id] => 2
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[3] => Array
(
[department_id] => 4
[parent_id] => 2
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[4] => Array
(
[department_id] => 5
[parent_id] => 2
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[5] => Array
(
[department_id] => 6
[parent_id] => 2
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[6] => Array
(
[department_id] => 7
[parent_id] => 1
[department_code] => xs2q
[department_name] => 销售2区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[7] => Array
(
[department_id] => 8
[parent_id] => 7
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[8] => Array
(
[department_id] => 9
[parent_id] => 7
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[9] => Array
(
[department_id] => 10
[parent_id] => 7
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[10] => Array
(
[department_id] => 11
[parent_id] => 7
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[11] => Array
(
[department_id] => 12
[parent_id] => 0
[department_code] => xsb2
[department_name] => 销售部2
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[12] => Array
(
[department_id] => 13
[parent_id] => 12
[department_code] => xs3q
[department_name] => 销售3区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[13] => Array
(
[department_id] => 14
[parent_id] => 13
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[14] => Array
(
[department_id] => 15
[parent_id] => 13
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[15] => Array
(
[department_id] => 16
[parent_id] => 13
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[16] => Array
(
[department_id] => 17
[parent_id] => 13
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[17] => Array
(
[department_id] => 18
[parent_id] => 12
[department_code] => xs4q
[department_name] => 销售4区
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[18] => Array
(
[department_id] => 19
[parent_id] => 18
[department_code] => xs1ks
[department_name] => 销售1科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039207
[add_user_id] => 1
[edit_time] => 1470039207
[edit_user_id] => 1
)
[19] => Array
(
[department_id] => 20
[parent_id] => 18
[department_code] => xs2ks
[department_name] => 销售2科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039208
[add_user_id] => 1
[edit_time] => 1470039208
[edit_user_id] => 1
)
[20] => Array
(
[department_id] => 21
[parent_id] => 18
[department_code] => xs3ks
[department_name] => 销售3科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039208
[add_user_id] => 1
[edit_time] => 1470039208
[edit_user_id] => 1
)
[21] => Array
(
[department_id] => 22
[parent_id] => 18
[department_code] => xs4ks
[department_name] => 销售4科室
[department_phone] =>
[department_cornet] =>
[department_description] =>
[department_sort] => 0
[is_delete] => 1
[department_status] => 1
[add_time] => 1470039208
[add_user_id] => 1
[edit_time] => 1470039208
[edit_user_id] => 1
)
)
这个还是三级分类有可能搜到的是最后一级 那还要找俩级 怎么去合并啊
相关阅读:
@connect是什么操作?
安卓机微信打开HTML5会卡顿
jquery 多个DIV展开折叠
php重载与重写的区别?重载与其他语言(如java)有何差异?
TP框架的这句话哪里不对?
sysctl,launchctl,ulimit三者的关系和异同
关于viewpager的滑动
Android下大部分国产浏览器不响应html5的退出全屏的api,这个如何解决?
类似很久以前文字冒险游戏的指令系统
关于oracle 10g重复插入数据的问题
Django中调用可执行文件,如何添加路径
SQLAlchemy 模型定义中 __init__() 的用途是什么?
IDEA怎么去掉代码块之间的竖线
是否应该对“评论”字段也增设“投票” 机制?
ionic中的modal中如何实现导航视图
amaze ui touch怎么配置环境啊!!!!
如何使用node+jquery ajax实现图片上传?
关于UIPageViewController
请教一个 d2d 的内存释放问题
Hexo deploy报错: TypeError : undefined is not a function