1차가 같은 2차 분류만 뽑기 채택완료
쭌111
3년 전
조회 2,106
현재
1차 - 지역
2차 - 컨텐츠
3차 - 예약
이렇게 분류로 해서 뿌려주고 있는데
처음 화면에서
1차 분류로 지역을 선택하고
다음 페이지에서 1차 지역에 맞는 2차 분류들을 뽑아오고 싶습니다..
현재는 1차 분류 선택 후 다음페이지에 모든 2차분류가 다 추출되고 있습니다.
10 선택시 1010 1020 1030 만 노출
listcategory.php 파일들 뒤져봐도 너무 어렵네요ㅠㅠ
1차 추출 코드
</p>
<p><?php</p>
<p>if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가</p>
<p> </p>
<p>$str = '';</p>
<p>$exists = false;</p>
<p> </p>
<p>$ca_id_len = strlen($ca_id);</p>
<p>$len2 = $ca_id_len + 2;</p>
<p>$len4 = $ca_id_len + 4;</p>
<p> </p>
<p>$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id%' and length(ca_id) = $len2 and ca_use = '1' order by ca_order, ca_id ";</p>
<p>$result = sql_query($sql);</p>
<p>while ($row=sql_fetch_array($result)) {</p>
<p> </p>
<p> $row2 = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_item_table']} where (ca_id like '{$row['ca_id']}%' or ca_id2 like '{$row['ca_id']}%' or ca_id3 like '{$row['ca_id']}%') and it_use = '1' ");</p>
<p> </p>
<p> $str .= '<li><a href="'.G5_THEME_URL.'/html/serchpick.php"><h2 class="'.$row['ca_id'].'">'.$row['ca_name'].'</h2> <span>준비된 컨텐츠 '.$row2['cnt'].'개</span> </a><i class="xi-angle-right"></i></li>';</p>
<p> $exists = true;</p>
<p>}</p>
<p> </p>
<p>if ($exists) {</p>
<p> </p>
<p> // add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨</p>
<p> add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">', 0);</p>
<p>?></p>
<p> </p>
<p><!-- 상품분류 1 시작 { --></p>
<p><div class="serch_list"></p>
<p> <!-- <h2>현재 상품 분류와 관련된 분류</h2> --></p>
<p> <ul></p>
<p> <?php echo $str; ?></p>
<p> </ul></p>
<p></div></p>
<p><!-- } 상품분류 1 끝 --></p>
<p> </p>
<p><?php }</p>
<p>
2차 추출 코드
</p>
<p><?php</p>
<p>if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가</p>
<p> </p>
<p>$str = '';</p>
<p>$exists = false;</p>
<p> </p>
<p>$depth2_ca_id = substr($ca_id, 0, 2);</p>
<p> </p>
<p>$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}%' and length(ca_id) = 4 and ca_use = '1' order by ca_id, ca_order ";</p>
<p>$result = sql_query($sql);</p>
<p>while ($row=sql_fetch_array($result)) {</p>
<p> if (preg_match("/^{$row['ca_id']}/", $ca_id))</p>
<p> $sct_ct_here = 'sct_ct_here';</p>
<p> else</p>
<p> $sct_ct_here = '';</p>
<p> $str .= '<li><a href="'.shop_category_url($row['ca_id']).'" class="'.$sct_ct_here.'">'.$row['ca_name'].' <span>준비된 컨텐츠 보러가기</span> </a><i class="xi-angle-right"></i></li>';</p>
<p> $exists = true;</p>
<p>}</p>
<p> </p>
<p>if ($exists) {</p>
<p> </p>
<p> // add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨</p>
<p> add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">', 0);</p>
<p>?></p>
<p> </p>
<p><!-- 상품분류 3 시작 { --></p>
<p> <ul></p>
<p> <?php echo $str; ?></p>
<p> </ul></p>
<p><!-- } 상품분류 3 끝 --></p>
<p> </p>
<p><?php }</p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
3년 전
2차" 페이지에서 이 변수가
$depth2_ca_id
안 넘어 오는 것 같습니다.
다음은 추천 query입니다.
1차 query
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__' and length(ca_id) = $len2 and ca_use = '1' order by ca_order, ca_id ";
$result = sql_query($sql);
2차 query
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}__' and length(ca_id) = 4 and ca_use = '1' order by ca_id, ca_order ";
$result = sql_query($sql);
로그인 후 평가할 수 있습니다
답변에 대한 댓글 11개
�
쭌111
3년 전
�
엑스엠엘
3년 전
echo $sql;
해서 각각 페이지에 나온 것을 올려 보세요.
해서 각각 페이지에 나온 것을 올려 보세요.
�
쭌111
3년 전
말씀해주신대로 다시 해보니 추출은 되었는데
1차에서 10 1010 101010 101020 1020 1030 추출이 되고
2차에도 동일합니다.
1차에서 10 20 30 40 50 60
그리고 만약 10 클릭시
2차에서 1010 1020 1030 만 추출을 하고싶습니다ㅠㅠ
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id%' and ca_use = '1' order by ca_order, ca_id ";
2차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}%' and ca_use = '1' order by ca_id, ca_order ";
1차에서 10 1010 101010 101020 1020 1030 추출이 되고
2차에도 동일합니다.
1차에서 10 20 30 40 50 60
그리고 만약 10 클릭시
2차에서 1010 1020 1030 만 추출을 하고싶습니다ㅠㅠ
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id%' and ca_use = '1' order by ca_order, ca_id ";
2차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}%' and ca_use = '1' order by ca_id, ca_order ";
�
엑스엠엘
3년 전
query문은
소스에 있는 것 말고
echo $sql;
해서 나온 것을 올려 보세요.
소스에 있는 것 말고
echo $sql;
해서 나온 것을 올려 보세요.
�
쭌111
3년 전
1번 echo $sql
select ca_id, ca_name from g5_shop_category where ca_id like '%' and ca_use = '1' order by ca_order, ca_id
2번 echo $sql
select ca_id, ca_name from g5_shop_category where ca_id like '%' and ca_use = '1' order by ca_id, ca_order select ca_id, ca_name from g5_shop_category where ca_id like '%' and ca_use = '1' order by ca_id, ca_order
입니다
select ca_id, ca_name from g5_shop_category where ca_id like '%' and ca_use = '1' order by ca_order, ca_id
2번 echo $sql
select ca_id, ca_name from g5_shop_category where ca_id like '%' and ca_use = '1' order by ca_id, ca_order select ca_id, ca_name from g5_shop_category where ca_id like '%' and ca_use = '1' order by ca_id, ca_order
입니다
�
엑스엠엘
3년 전
mysql like에서 _ (undersocre)가 의미가 있는 것입니다.
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id%' and ca_use = '1' order by ca_order, ca_id ";
2차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}%' and ca_use = '1' order by ca_id, ca_order ";
이것은
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__%' and ca_use = '1' order by ca_order, ca_id ";
2차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}__' and ca_use = '1' order by ca_id, ca_order ";
이렇게 해 보세요.
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id%' and ca_use = '1' order by ca_order, ca_id ";
2차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}%' and ca_use = '1' order by ca_id, ca_order ";
이것은
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__%' and ca_use = '1' order by ca_order, ca_id ";
2차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}__' and ca_use = '1' order by ca_id, ca_order ";
이렇게 해 보세요.
�
쭌111
3년 전
여전히 2차페이지에서 10 1010 101010 101020 1020 1030 1040 20 2020 201010 ... 이렇게 전부 나옵니다ㅠ
구현 설명을 추가하자면
현재는 serch.php 에서
1차에서 10 20 30 40 50 60 카테고리 추출 후 링크 클릭시
serchpick.php로 이동합니다.
1차에서 10을 선택시
serchpick.php에서는 1010 1020 1030을 추출해야 합니다.
꼭 이렇게 php 파일을 변경하지 않고도 다른 구현 방법이 있다면 추천 부탁드립니다..ㅠ
구현 설명을 추가하자면
현재는 serch.php 에서
1차에서 10 20 30 40 50 60 카테고리 추출 후 링크 클릭시
serchpick.php로 이동합니다.
1차에서 10을 선택시
serchpick.php에서는 1010 1020 1030을 추출해야 합니다.
꼭 이렇게 php 파일을 변경하지 않고도 다른 구현 방법이 있다면 추천 부탁드립니다..ㅠ
�
엑스엠엘
3년 전
오타가 있었네요.
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__' and ca_use = '1' order by ca_order, ca_id ";
1차 수정본
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__' and ca_use = '1' order by ca_order, ca_id ";
�
엑스엠엘
3년 전
2차에서
여전히 2차페이지에서 10 1010 101010 101020 1020 1030 1040 20 2020 201010 ... 이렇게 전부 나옵니다ㅠ
==
라면
$depth2_ca_id
변수가 안 넘어 온 거 같습니다.
%가 아니라 _ _ 두 개로 바꾸세요. (공백 없이)
여전히 2차페이지에서 10 1010 101010 101020 1020 1030 1040 20 2020 201010 ... 이렇게 전부 나옵니다ㅠ
==
라면
$depth2_ca_id
변수가 안 넘어 온 거 같습니다.
%가 아니라 _ _ 두 개로 바꾸세요. (공백 없이)
�
쭌111
3년 전
번거롭게 해드려서 죄송합니다ㅠ 헷갈려서 그러는데
첫번째 페이지 serch.php에
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__' and ca_use = '1' order by ca_order, ca_id ";
두번째 페이지 serchpick.php에
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}__' and ca_use = '1' order by ca_id, ca_order ";
이 쿼리문이 맞을까요??
첫번째 페이지 serch.php에
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '__' and ca_use = '1' order by ca_order, ca_id ";
두번째 페이지 serchpick.php에
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}__' and ca_use = '1' order by ca_id, ca_order ";
이 쿼리문이 맞을까요??
�
엑스엠엘
3년 전
예 맞는 것 같네요.
확실하려면
echo $sql 해서 나온 query를 확인해 보세요.
확실하려면
echo $sql 해서 나온 query를 확인해 보세요.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
카테고리가 아예 추출되지 않습니다..