php
数据表
$sql = "select id,class_cid,class_name from
hl_goods_class
order by id asc ";$items = $this->fetch_list($sql);
for($i=1;$i<=count($items);$i++){
$aa[$i] = $items[$i-1];
}
$tree = array();
foreach ($aa as $item) {
if (isset($aa[$item['class_cid']])) {
$aa[$item['class_cid']]['son'][] = &$aa[$item['id']];
} else {
$tree[] = &$aa[$item['id']];
}
}
return $tree;
网友评论