如何仅查询第二级别类别?

this is my code, it displays all the categories like

A
-A.1
-A.2
B
-B.1
-B.2

And now i want it displays only

A.1
A.2
B.1
B.2

Any idea?

    function current_categories($m,$id){
    $cat_array=array();
    $sql = "select * from `category`";
    $query = DB::Query($sql);
        while($row = DB::fetch_array($query)){
            $cat_array[] = array($row['id'],$row['name'],$row['classid'],$row['sort']);
        } 
        if($id==""){
            $id=0;
        }
    $n = str_pad('',$m,'-',STR_PAD_LEFT);
    $n = str_replace("-","    ",$n);
    for($i=0;$i<count($cat_array);$i++){
        if($cat_array[$i][2]==$id){
        echo "<li>"."<a href=\"/team/index.php?gid=".$cat_array[$i][0]."\">".$cat_array[$i][1]."</a></li>"; 
    current_categories($m+2,$cat_array[$i][0]);
        }
    }
}

I don't know what value you put in as classid for the toplevel classid values. NULL or -1 perhaps?

function second_level_categories(){
    $sql = " SELECT lvl2.* FROM `category` as lvl1 "
          ." JOIN `category` as lvl2"
          ."     ON lvl1.id = lvl2.parent_id"
          ." WHERE lvl1.parent_id=VALUE_FOR_TOP_LEVEL"
          ." ORDER BY lvl1.sort ASC, lvl2.sort ASC"

    $result = DB::Query($sql);
    while($category = DB::fetch_array($result)){
        echo '<li><a href="/team/index.php?gid='.$category['id'].'">"';
        echo $category['name'];
        echo '</a></li>';
    } 
}