카테고리 개수 출력 질문입니다.
본문
어제 질문을 올린뒤에 많은...수정을 통해 거의 목표치에 도달하게 된 늘 초보자..인사드립니다.
최신글에 올려져있는 카테고리 옆에 개수를 추가시키위해 작업을 하던 도중
밑의 소스 중 $row1 = sql_fetch("select count(*) as cate_cnt from g5_write_Document where ca_name = '.$ca_name.'");
이부분이 해당 카테고리를 카운트하는 부분인데 위의 ca_name= '' 이부분에 각 카테고리 명을 적으면 해당 카테고리 갯수가 출력이 되는데 ㅜ각 카테고리의 갯수를 출력을 하기 위해선 ca_name부분에 어떤 명령어를 넣어야 출력이 될까요 ?? ㅜ 위처럼 $ca_name을 하니깐 적용이 되질 않네요 ㅜ
$is_category = false;
$category_option = '';
if ($board['bo_use_category']) {
$is_category = true;
$category_href = G5_BBS_URL.'/board.php?bo_table='.$bo_table;
$category_href_edit = G5_ADMIN_URL.'/board_form.php?w=u&bo_table=Document&sst=&sod=&sfl=&stx=&page=';
$categories = explode('|', $board['bo_category_list']); // 구분자가 , 로 되어 있음
$row1 = sql_fetch("select count(*) as cate_cnt from g5_write_Document where ca_name = '.$ca_name.'");
for ($i=0; $i<count($categories); $i++) {
$category = trim($categories[$i]);
if ($category=='') continue;
$category_option .= '<li onclick="showCa(\''.$category.'\')"><a class="ca_list" style="color:#B3B3B3;" href="'.($category_href."&sca=".urlencode($category)).'"';
$category_msg = '';
if ($category==$sca) { // 현재 선택된 카테고리라면
$category_option .= ' id="bo_cate_on"';
$category_msg = '<span class="sound_only">열린 분류 </span>';
}
$category_option .= '>'.$category_msg.$category.'('.$row1['cate_cnt'].')</a>';
if($member[mb_level] > 4){
$category_option .= '<a class="category_edit" style="color:#B3B3B3;" href="'.($category_href_edit).'">수정</a></li>';
}
}
}
답변 2
$row1 = sql_fetch("select count(*) as cate_cnt from g5_write_Document where ca_name = '.$category.'");
로 바꾸시고 위치는 f ($category=='') continue; 아래에 해보세요