트리 형식 카테고리 출력
include_once(“./_common.php”);
$sql_common = ” from $g4[shop_category_table] “;
?>
<ul>
<li class=”cat_list0″>
<div class=”wrap”>
<div class=”plus” id=”firstCategory”></div>
<div class=”name”>전체</div>
</div>
</li>
<li class=”nodisplay” id=”categoryList-1″>
<ul>
<?php // 1차 분류
$sql_where = ” where char_length(ca_code) = 3 order by ca_code asc “;
$sql = ” select ca_name, ca_code
$sql_common
$sql_where “;
$result = sql_query($sql);
for($i = 0; $row = sql_fetch_array($result); $i++ ) {
?>
<li class=”cat_list1″>
<div class=”wrap”>
<div class=”plus”></div>
<div class=”name”><?=get_text($row[ca_name])?></div>
</div>
</li>
<li class=”nodisplay”>
<ul>
<?php
$sql_where2 = ” where char_length(ca_code) = 5 and substr(ca_code, 1, 3) = ‘$row[ca_code]’ order by ca_code asc “;
$sql2 = ” select ca_name, ca_code
$sql_common
$sql_where2 “;
$result2 = sql_query($sql2);
for($j = 0; $row2 = sql_fetch_array($result2); $j++ ) {
?>
<li class=”cat_list2″>
<div class=”wrap”>
<div class=”plus”></div>
<div class=”name”><?=get_text($row2[ca_name])?></div>
</div>
</li>
<li class=”nodisplay”>
<ul>
<?php
$sql_where3 = ” where char_length(ca_code) = 7 and substr(ca_code, 1, 5) = ‘$row2[ca_code]’ order by ca_code asc “;
$sql3 = ” select ca_name, ca_code
$sql_common
$sql_where3 “;
$result3 = sql_query($sql3);
for($j = 0; $row3 = sql_fetch_array($result3); $j++ ) {
?>
<li class=”cat_list3″>
<div class=”wrap”>
<div class=”plus”></div>
<div class=”name”><?=get_text($row2[ca_name])?></div>
</div>
</li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
</li>
</ul>
#categoryList ul { margin: 0; padding: 0; list-style: none; }
#categoryList li { float: left; }
#categoryList .cat_list0 { width: 196px; height: 18px; padding-top: 6px; background: url(‘../images/item_category_folder.gif’) no-repeat 14px 5px; }
#categoryList .cat_list1 { width: 180px; height: 18px; padding-top: 6px; padding-left: 16px; background: url(‘../images/item_category_folder.gif’) no-repeat 30px 5px; }
#categoryList .cat_list2 { width: 164px; height: 18px; padding-top: 6px; padding-left: 32px; background: url(‘../images/item_category_folder.gif’) no-repeat 46px 5px; }
#categoryList .cat_list3 { width: 148px; height: 18px; padding-top: 6px; padding-left: 48px; background: url(‘../images/item_category_folder.gif’) no-repeat 62px 5px; }
#categoryList .wrap { float: left; }
#categoryList .wrap .minus { float: left; width: 35px; height: 9px; background: url(‘../images/item_category_minus.gif’) no-repeat left top; cursor: pointer; }
#categoryList .wrap .plus { float: left; width: 35px; height: 9px; background: url(‘../images/item_category_plus.gif’) no-repeat left top; cursor: pointer; }
#categoryList .name { float: left; top: 0; color: #333; font-weight: bold; }
#categoryList .nodisplay { display: none; }
#categoryForm { float: right; width: 514px; margin-top: 35px; }
여기다 이제 + 버튼 클릭하면 하위 카테고리가 보이도록 해야하는데.. 이게 쉽지 않을 것 같다. 자바스크립트를
잘 알면 쉽게 할 수 있을 것 같기도 한데.. 난 뭐 아직 잘 모르니까 내가 할 수 있는 범위 안에서 뭔가 해봐야겠다.