테스트 사이트 - 개발 중인 베타 버전입니다

가로 카테고리메뉴 1차, 2차, 3차 카테고리 모두 출력하기 (listcategory.inc.php) ul, li 버전

· 14년 전 · 565 · 2

<?
include_once("./_common.php");

// 1차 카테고리 출력
$str = "";
$exists = false;

$depth2_ca_id = substr($ca_id, 0, 2);

$sql = " select ca_id, ca_name from $g4[yc4_category_table] where ca_id like '${depth2_ca_id}%' and length(ca_id) = 4 and ca_use = '1' order by ca_id ";
$result = sql_query($sql);
$list_mod = 5;  ///////////////////////////////////////////////////// 가로 갯수
for ($i=0; $row=sql_fetch_array($result); $i++) {
    if ($i > 0 && $i % $list_mod == 0) {
        $str .= "\n";
    }

    $str .= "<li><a href='./list.php?ca_id=$row[ca_id]'>";

    if (preg_match("/^$row[ca_id]/", $ca_id))
        $font = "<font style='color:ff6600;font-size:11;font-weight:bold;'>";
    else
        $font = "<font style='font-size:11;'>";
    $str .= "{$font}$row[ca_name]</font>";
    $exists = true;

    $str .= "</a>&nbsp;</li>";
}

if ($exists) {
    echo "
    <ul>
    $str
    </ul>";
}
 
// 2차 카테고리 출력 (1차 분류에 속한 것만)
$str2 = "";
$exists2 = false;
$depth2_ca_id = substr($ca_id, 0, 4);

$sql2 = " select ca_id, ca_name from $g4[yc4_category_table] where ca_id like '${depth2_ca_id}%' and length(ca_id) = 6 and ca_use = '1'  order by ca_id ";
$result2 = sql_query($sql2);
//$str2 .= "<td style='border-width:1; border-color:#dddddd; border-style:solid;'><table width=100% border=0><tr>";
$list_mod2 = 5;   ///////////////////////////////////////////////////// 가로 갯수
for ($j=0; $row=sql_fetch_array($result2); $i++) {
    if ($j > 0 && $j % $list_mod2 == 0) {
        $str2 .= "\n";
    }

    $str2 .= "<li><a href='./list.php?ca_id=$row[ca_id]'>";

    if (preg_match("/^$row[ca_id]/", $ca_id))
        $font = "<font style='color:0099ff;font-size:11;font-weight:bold;'>";
    else
        $font = "<font style='font-size:11;'>";
    $str2 .= "{$font}$row[ca_name]</font>";
    $exists2 = true;

    $str2 .= "</a>&nbsp;</li>";
}

if (substr($ca_id,2,6)){
if ($exists2) {
    echo "
    <ul>
    $str2
    </ul>";
} }

// 3차 카테고리 출력 (2차 분류에 속한것만)
$str3 = "";
$exists3 = false;

$depth2_ca_id = substr($ca_id, 0, 6);

$sql3 = " select ca_id, ca_name from $g4[yc4_category_table] where ca_id like '${depth2_ca_id}%' and length(ca_id) = 8 and ca_use = '1' order by ca_id ";
$result3 = sql_query($sql3);
$list_mod3 = 5;  ///////////////////////////////////////////////////// 가로 갯수
for ($l=0; $row=sql_fetch_array($result3); $i++) {
    if ($l > 0 && $l % $list_mod3 == 0) {
        $str3 .= "\n";
    }

    $str3 .= "<li><a href='./list.php?ca_id=$row[ca_id]'>";

    if (preg_match("/^$row[ca_id]/", $ca_id))
        $font = "<font style='color:000000;font-size:11;font-weight:bold;'>";
    else
        $font = "<font style='font-size:11;'>";
    $str3 .= "{$font}$row[ca_name]</font>";
    $exists3 = true;

    $str3 .= "</a>&nbsp;</li>";
}

if (substr($ca_id,4,4)){
if ($exists3) {
    echo "
    <ul>
    $str3
    </ul>";
} }
?>

 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 2개

http://sir.co.kr/bbs/board.php?bo_table=yc4_tiptech&wr_id=1096&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%24list_mod3+%3D+5%3B&spt=0
글과 달리.. 가로 출력이 되지 않고 일자로 출력됩니다~
float관련해서 설정이 들어가야될듯합니다..

for ($j=0; $row=sql_fetch_array($result2); $i++) {
이부분도 오류 $i =>$j
안되네요 ㅡ.ㅡ

게시글 목록

번호 제목
1111
1107
1105
1102
1099
1098
1097
1101
1096
1132
1094
1092
1091
1088
1087
1083
1082
1076
1068
1056