<?php
// 1단계 분류
$hsql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where length(ca_id) = '2' and ca_use = '1' order by ca_id ";
$hresult = sql_query($hsql);
$count = count($hresult);
for ($i=0; $row=sql_fetch_array($hresult); $i++) {
?>
<div class="lnb-box">
<h2><a href="<?php echo G5_SHOP_URL.'/list.php?ca_id='.$row['ca_id']; ?>"><?php echo $row['ca_name']; ?></a></h2>
<?php
// 2단계 분류
$sql2 = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where LENGTH(ca_id) = '4' and SUBSTRING(ca_id,1,2) = '{$row['ca_id']}' and ca_use = '1' order by ca_id ";
$result2 = sql_query($sql2);
for ($j=0; $row2=sql_fetch_array($result2); $j++) {
if ($j==0) echo '<ul>';
$active = $row2['ca_id'] == substr($_GET['ca_id'], 0, 4) ? "class='active'" : "";
?>
<li <?php echo $active?>><a href="<?php echo G5_SHOP_URL; ?>/list.php?ca_id=<?php echo $row2['ca_id']; ?>"><?php echo $row2['ca_name']; ?></a></li>
<?php }
if ($j>0) echo '</ul>';
?>
</div>
<?php } ?>