mobile/include/lib_goods.php
function get_child_tree($tree_id = 0){ $three_arr = array(); $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$tree_id' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) {/*SELECT cat_id, cat_name, parent_id, is_showFROM ecs_categoryWHERE parent_id =$type_id AND is_show=1ORDER BY sort_order ASC,cat_id ASC;*/ $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$tree_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($child_sql); foreach ($res AS $row) { if ($row['is_show']) $three_arr[$row['cat_id']]['id'] = $row['cat_id']; $three_arr[$row['cat_id']]['name'] = $row['cat_name']; $three_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } return $three_arr;}