좀 알려주세요..... > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

좀 알려주세요..... 정보

좀 알려주세요.....

본문

디비테이블명  g4_category

idx    c_code    c_pcode    c_depth    c_name      c_sort     
1          a123      b123            0            남자            1           
2          a675      c234            0            여자            2         
3          a534      c234            1            티셔츠
4          a764      b123            1            티셔츠
5          a897      c234            1            속옷

간략히 설명을 드리면 c_code 는 주소가 될부분으로 랜덤생성입니다.(각각다르게)
 c_depth의 값이 0 이면 ->  1차메뉴  , 값이  1  이면  -> 2차메뉴
c_pcode의 값은 1차메뉴에 속한 2차값을 나타내는 부분입니다.

c_pcode의 값이 같으면 같은 분류 그중에서  c_depth 값이 0이면 1차메뉴 1이면 2차메뉴입니다.


예를 들어 idx 1번을 보면  c_depth 값은 0 그러면 1차메뉴 그곳의 c_pcode값은 b123 입니다.
idx 3번도 c_pcode값이 b123이며 c_depth 값은 1 그러므로 idx 1번의 서브메뉴가 됩니다.
c_pcode값으로 2차메뉴가 정렬된다고 설명드려야 하나?? ^^
하여튼 이런식으로 1-2차 카테고리가 지정됩니다.
c_sort는 1차메뉴에서 출력 순서가 됩니다.

여기서 질문입니다.
아래 php소스에서 1차값에 해당하는 2차값만을 불러오고 싶습니다.





//여기는 1차메뉴
<?
$QUERY = "select * from g4_category where c_depth='0' order by c_sort asc";
$RESULT = mysql_query($QUERY);
?>
//여기는 2차메뉴
<?
$QUERY2 = "select * from g4_category where c_depth='1' and c_pcode='$LIST[c_code]' order by c_name asc";
$RESULT2 = mysql_query($QUERY2);
?>
<?
while($LIST = mysql_fetch_array($RESULT))
{
?>
<?=$LIST[c_name]?>

<?
}
?>

이렇게 하면 1차메뉴는 뽑아옵니다.
하지만 2차메뉴는 나오질 않네요.

2차메뉴를 뽑고 싶으면 어떻게 하는 방법이 있을까요?
  • 복사

댓글 전체

<?
$QUERY = "select * from g4_category where c_depth='0' order by c_sort asc";
$RESULT = mysql_query($QUERY);

while($LIST = mysql_fetch_array($RESULT))  {
echo $LIST[c_name]."<br/>";

$QUERY2 = "select * from g4_category where c_depth='1' and c_pcode='$LIST[c_code]' order by c_name asc";
$RESULT2 = mysql_query($QUERY2);

while($LIST2 = mysql_fetch_array($RESULT2))  {
echo $LIST2[c_name]."<br/>";
}
}
?>
감사합니다. 잘됩니다. 제가 2-3일 고생한것이 몇분만에 해결해주셨네요~ ^^
가로로 출력되게 하고 싶은데요....
<table cellpadding="0" cellspacing="0" width="100%">

<?
$QUERY = "select * from g4_category where c_depth='0' order by c_sort asc";
$RESULT = mysql_query($QUERY);
?>

<?
while($LIST = mysql_fetch_array($RESULT))  {
echo "<tr><td width='100'>".$LIST[c_name]."</td>";

$QUERY2 = "select * from g4_category where c_depth='1' and c_pcode='$LIST[c_code]' order by c_regday asc";
$RESULT2 = mysql_query($QUERY2);

while($LIST2 = mysql_fetch_array($RESULT2))  {
echo "<td width='80'>".$LIST2[c_name]."</td>";
}
}
?>
</tr>
</table>

이렇게 하니 출력은 되는것 소스가 맞나 한번 봐주실래요?
© SIRSOFT
현재 페이지 제일 처음으로