/** * 分类层级列表 */ function getTree($data, $pid = 0, $deep = 0) { $array = array(); foreach ($data as $key => $row) { if ($row["pid"] == $pid) { $row["deep"] = $deep; $row["deepTag"] = getDeepTag($deep); $this->listTree[] = $row; $array = $this->getTree($data, $row["id"], $deep + 1); } } if (count($array) > 0) { return $array; } else { return $this->listTree; } }
function getCategoryOptions($pid = 0, $level = 0) { global $DB; $str = ''; $arr = $DB->fetchAll("SELECT * FROM `t_sort` where pid=? order by weight desc, id desc", array($pid)); foreach ($arr as $key => $row) { $str .= '<option value="' . $row['id'] . '">' . getDeepTag($level) . $row['title'] . '</option>'; $str .= getCategoryOptions($row['id'], $level + 1); } return $str; }