$str = "";
$exists = false;
$ca_id_len = strlen($ca_id);
$len2 = $ca_id_len + 2;
$len4 = $ca_id_len + 4;
// 최하위 분류의 경우 상단에 동일한 레벨의 분류를 출력해주는 코드
if (!$exists) {
$str = "";
$tmp_ca_id = substr($ca_id, 0, strlen($ca_id)-2);
$tmp_ca_id_len = strlen($tmp_ca_id);
$len2 = $tmp_ca_id_len + 2;
$len4 = $tmp_ca_id_len + 4;
// 차차기 분류의 건수를 얻음
$sql = " select count(*) as cnt from $g4[yc4_category_table]
where ca_id like '$tmp_ca_id%'
and ca_use = '1'
and length(ca_id) = $len4 ";
$row = sql_fetch($sql);
$cnt = $row['cnt'];
if (!$cnt)
$str .= "
| ";
$sql = " select ca_id, ca_name from $g4[yc4_category_table]
where ca_id like '$tmp_ca_id%'
and ca_use = '1'
and length(ca_id) = $len2 order by ca_id ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result)) {
$style = "";
if ($ca_id == $row[ca_id])
$style = " class='accent' ";
if ($cnt) {
$str .= " |
| ";
$str .= "| · $row[ca_name] | ";
$sql2 = " select ca_id, ca_name from $g4[yc4_category_table]
where ca_id like '$row[ca_id]%'
and ca_use = '1'
and length(ca_id) = $len4 order by ca_id ";
$result2 = sql_query($sql2);
$k=0;
while ($row2=sql_fetch_array($result2)) {
if (!$k)
$str .= "| | ";
$str .= "$row2[ca_name] ";
$k++;
}
//if (!$k) $str .= " | | ";
$str .= " |
| | ";
} else {
$str .= "$row[ca_name] ";
}
$exists = true;
}
if (!$cnt)
$str .= " |
";
}
if ($exists) {
echo "
";
}
?>