카테고리 숫자 질문입니다. 정보
카테고리 숫자 질문입니다.본문
안녕하세요.
제가 초보인데요.
위에그림에서
파란색 괄호 숫자 부분이 그냥 각 카테고리내에 있는 글의 숫자가 되게 하고 싶은데
실력이 딸려서 안되네여.........ㅠㅠ
아래 코드 보시고....
알려주시기를 부탁드립니다.
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="left" valign="top" style='padding: 5px; word-break:break-all;'> <b><a href="<?=$list_href?>">【전체보기】</a></b><br>
<br><?
if ($is_category) {
?>
<table cellspacing=0 cellpadding=0 border=0>
<tr bgcolor=''><?
$icon =" <img src='".$board_skin_path."/img/coffeemaru.gif' border=0 width=16 height=16 style='vertical-align:middle;'>";
/*/###################################################### 참고사항 및 테스트
foreach($list as $value){
$array = explode(",", $value['ca_name']);
for ($j=0; $j<count($array); $j++){
$cat = $array[$j];
//if (isset($sca)){
if (!empty($sca)){
//if ($sca == $cat){//cat에서 하나만 일치해도 참 값이 나올수 있게 하려면?
if (stristr( $cat, $sca)){//rolo님 소스 $cat안에 $sca 문자열이 포함 되어 있는지 검사
echo $value['wr_subject'] . '/' . $value['ca_name'] . '/' . $value['datetime2']. " ";
echo "1";
}
else{
echo "2";
}
}//if
}//for
}//foreach
/*///2006년 9월 2일 토요일 플록
//###################################################### 기존 사용
$key = explode("|", $board['bo_category_list']);
$cnt = 1;
foreach( $key as $ctg){
//$ctg_size= count( $key);//카테고리 카운트
//echo $ctg_size;
?>
<td align="left" valign='top' style='padding:0px;border:0px solid silver;'><?
if(trim($ctg)){
$tmp_write_table = $g4['write_prefix'] . $board['bo_table'];
$intime = date("Y-m-d H:i:s", time()-3600*$board['bo_new']);
//전체 및 분류별 카운트 지정한 시간내 분류별 새글
$sql = mysql_query(" select count(wr_parent) as wr_parent from $tmp_write_table where wr_is_comment = '' ");
$row = mysql_fetch_array($sql); //코멘트 제외한 게시판 전체글 카운트
$sql_ctg = mysql_query(" select count(wr_parent) as wr_parent from $tmp_write_table where instr( ca_name, '," . $ctg . ",') and wr_is_comment = '' "); //where instr( 필드, '검색어')
$row_ctg = mysql_fetch_array($sql_ctg); //코멘트 제외한 카테고리별 카운트
$sql_new = mysql_query(" select count(wr_datetime) as wr_datetime from $tmp_write_table where instr( ca_name, '," . $ctg . ",') and wr_is_comment = '' and wr_datetime >= '$intime' ");//카테고리별 최신글 카운트
$row_new = mysql_fetch_array($sql_new);
$wr_cnt = $row['wr_parent'];
$ctg_cnt = $row_ctg['wr_parent'];
$new_cnt = $row_new['wr_datetime'];
if ($ctg_cnt || $new_cnt > 0){
$nc_icon = "<span class='new'>(" . $ctg_cnt . ")</span>";
}
else{
$nc_icon = "";
}
if ($wr_cnt || $ctg_cnt > 0){
$wc_icon = "<span class='new'>(" . $ctg_cnt . '/' . $wr_cnt . ")</span>";
}
else{
$wc_icon = "";
}
//링크에서 한글로된 카데고리 이름을 urlencode시킴
$sca_url = urlencode($ctg);
$style = "";
$spos = ($sca)?"$sca":"$stx";
if ($ctg == $spos)//해당 분류 표시
$style = " style='font-weight:bold; color:darkblue;' ";
$ca_name = "<span $style>" . cut_str($ctg, 18) . "</span>";
?><span style='padding-top:5px;padding-bottom:5px;font-size:9pt; '><?//=$str //test?><?=$icon?><a href='<?=$g4['bbs_path']?>/board.php?bo_table=<?=$bo_table?>&sca=<?=$sca_url?>'><?=$ca_name?></a><?=$nc_icon?></span><?
?> </td>
<?
if ($cnt == $cols) {
$cnt = 0;
?></tr><tr><?
}
$cnt++;
}//ctg
}//foreach
?> </tr></table>
</td>
</tr>
</table>
제가 초보인데요.
위에그림에서
파란색 괄호 숫자 부분이 그냥 각 카테고리내에 있는 글의 숫자가 되게 하고 싶은데
실력이 딸려서 안되네여.........ㅠㅠ
아래 코드 보시고....
알려주시기를 부탁드립니다.
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="left" valign="top" style='padding: 5px; word-break:break-all;'> <b><a href="<?=$list_href?>">【전체보기】</a></b><br>
<br><?
if ($is_category) {
?>
<table cellspacing=0 cellpadding=0 border=0>
<tr bgcolor=''><?
$icon =" <img src='".$board_skin_path."/img/coffeemaru.gif' border=0 width=16 height=16 style='vertical-align:middle;'>";
/*/###################################################### 참고사항 및 테스트
foreach($list as $value){
$array = explode(",", $value['ca_name']);
for ($j=0; $j<count($array); $j++){
$cat = $array[$j];
//if (isset($sca)){
if (!empty($sca)){
//if ($sca == $cat){//cat에서 하나만 일치해도 참 값이 나올수 있게 하려면?
if (stristr( $cat, $sca)){//rolo님 소스 $cat안에 $sca 문자열이 포함 되어 있는지 검사
echo $value['wr_subject'] . '/' . $value['ca_name'] . '/' . $value['datetime2']. " ";
echo "1";
}
else{
echo "2";
}
}//if
}//for
}//foreach
/*///2006년 9월 2일 토요일 플록
//###################################################### 기존 사용
$key = explode("|", $board['bo_category_list']);
$cnt = 1;
foreach( $key as $ctg){
//$ctg_size= count( $key);//카테고리 카운트
//echo $ctg_size;
?>
<td align="left" valign='top' style='padding:0px;border:0px solid silver;'><?
if(trim($ctg)){
$tmp_write_table = $g4['write_prefix'] . $board['bo_table'];
$intime = date("Y-m-d H:i:s", time()-3600*$board['bo_new']);
//전체 및 분류별 카운트 지정한 시간내 분류별 새글
$sql = mysql_query(" select count(wr_parent) as wr_parent from $tmp_write_table where wr_is_comment = '' ");
$row = mysql_fetch_array($sql); //코멘트 제외한 게시판 전체글 카운트
$sql_ctg = mysql_query(" select count(wr_parent) as wr_parent from $tmp_write_table where instr( ca_name, '," . $ctg . ",') and wr_is_comment = '' "); //where instr( 필드, '검색어')
$row_ctg = mysql_fetch_array($sql_ctg); //코멘트 제외한 카테고리별 카운트
$sql_new = mysql_query(" select count(wr_datetime) as wr_datetime from $tmp_write_table where instr( ca_name, '," . $ctg . ",') and wr_is_comment = '' and wr_datetime >= '$intime' ");//카테고리별 최신글 카운트
$row_new = mysql_fetch_array($sql_new);
$wr_cnt = $row['wr_parent'];
$ctg_cnt = $row_ctg['wr_parent'];
$new_cnt = $row_new['wr_datetime'];
if ($ctg_cnt || $new_cnt > 0){
$nc_icon = "<span class='new'>(" . $ctg_cnt . ")</span>";
}
else{
$nc_icon = "";
}
if ($wr_cnt || $ctg_cnt > 0){
$wc_icon = "<span class='new'>(" . $ctg_cnt . '/' . $wr_cnt . ")</span>";
}
else{
$wc_icon = "";
}
//링크에서 한글로된 카데고리 이름을 urlencode시킴
$sca_url = urlencode($ctg);
$style = "";
$spos = ($sca)?"$sca":"$stx";
if ($ctg == $spos)//해당 분류 표시
$style = " style='font-weight:bold; color:darkblue;' ";
$ca_name = "<span $style>" . cut_str($ctg, 18) . "</span>";
?><span style='padding-top:5px;padding-bottom:5px;font-size:9pt; '><?//=$str //test?><?=$icon?><a href='<?=$g4['bbs_path']?>/board.php?bo_table=<?=$bo_table?>&sca=<?=$sca_url?>'><?=$ca_name?></a><?=$nc_icon?></span><?
?> </td>
<?
if ($cnt == $cols) {
$cnt = 0;
?></tr><tr><?
}
$cnt++;
}//ctg
}//foreach
?> </tr></table>
</td>
</tr>
</table>
댓글 전체
.. wr_is_comment = '0'
으로 해 보세요.
그리고, 조건이 wr_is_comment가 있다면
select count(wr_parent) as wr_parent... 보다는
select count(wr_id) as wr_parent 가 빠릅니다.
으로 해 보세요.
그리고, 조건이 wr_is_comment가 있다면
select count(wr_parent) as wr_parent... 보다는
select count(wr_id) as wr_parent 가 빠릅니다.