스크랩 개수 출력하기 (view, list 페이지에 출력)
글 내용 보기 view.skin.php 파일에 출력하기.
1. 게시판 스킨 폴더에 있는 view.skin.php 파일 상단 ?> 안쪽에 아래 내용 추가
// 현재 글 스크랩 개수 구하기
$sql = " select count(*) as cnt from {$g5['scrap_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$row = sql_fetch($sql);
$scrap_count = $row['cnt'];
1-1. view.skin.php 파일에서 스크랩 버튼 출력 부분을 이렇게 수정.
(추가된 부분 : <?php if($scrap_count > 0) echo "$scrap_count"; ?>)
<?php if ($scrap_href) { ?><a href="<?php echo $scrap_href; ?>" target="_blank" class="btn_b01" onclick="win_scrap(this.href); return false;">스크랩 <?php if($scrap_count > 0) echo "$scrap_count"; ?></a><?php } ?>
글 목록 list.skin.php 파일에 출력하기.
2. 게시판 스킨 폴더에 있는 list.skin.php 파일에서 for ($i=0; $i<count($list); $i++) { 바로 밑에 이렇게 추가
for ($i=0; $i<count($list); $i++) {
// 스크랩 개수 구하기
$sql = " select count(*) as cnt from {$g5['scrap_table']} where bo_table = '$bo_table' and wr_id = '{$list[$i]['wr_id']}' ";
$row = sql_fetch($sql);
$scrap_count = $row['cnt'];
2-1 list.skin.php 파일에서 출력하고 싶은 곳에 아래 내용 추가.
<?php echo $scrap_count ?>
참고 : http://sir.kr/g4_tiptech/542
1. 게시판 스킨 폴더에 있는 view.skin.php 파일 상단 ?> 안쪽에 아래 내용 추가
// 현재 글 스크랩 개수 구하기
$sql = " select count(*) as cnt from {$g5['scrap_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$row = sql_fetch($sql);
$scrap_count = $row['cnt'];
1-1. view.skin.php 파일에서 스크랩 버튼 출력 부분을 이렇게 수정.
(추가된 부분 : <?php if($scrap_count > 0) echo "$scrap_count"; ?>)
<?php if ($scrap_href) { ?><a href="<?php echo $scrap_href; ?>" target="_blank" class="btn_b01" onclick="win_scrap(this.href); return false;">스크랩 <?php if($scrap_count > 0) echo "$scrap_count"; ?></a><?php } ?>
글 목록 list.skin.php 파일에 출력하기.
2. 게시판 스킨 폴더에 있는 list.skin.php 파일에서 for ($i=0; $i<count($list); $i++) { 바로 밑에 이렇게 추가
for ($i=0; $i<count($list); $i++) {
// 스크랩 개수 구하기
$sql = " select count(*) as cnt from {$g5['scrap_table']} where bo_table = '$bo_table' and wr_id = '{$list[$i]['wr_id']}' ";
$row = sql_fetch($sql);
$scrap_count = $row['cnt'];
2-1 list.skin.php 파일에서 출력하고 싶은 곳에 아래 내용 추가.
<?php echo $scrap_count ?>
참고 : http://sir.kr/g4_tiptech/542
첨부파일
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 4개
목록에 스크랩 칸을 하나 추가해서 조회순처럼 소팅을 적용하려고 아래처럼 소스를 수정했는데요.
[code]
<th scope="col">번호</th>
<th scope="col">제목</th>
<th scope="col">글쓴이</th>
<th scope="col"><?php echo subject_sort_link('wr_datetime', $qstr2, 1) ?>날짜 <i class="fa fa-sort" aria-hidden="true"></i></a></th>
<?php if ($is_good) { ?><th scope="col"><?php echo subject_sort_link('wr_good', $qstr2, 1) ?>추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
<?php if ($is_nogood) { ?><th scope="col"><?php echo subject_sort_link('wr_nogood', $qstr2, 1) ?>비추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
<th scope="col"><?php echo subject_sort_link('wr_hit', $qstr2, 1) ?>조회 <i class="fa fa-sort" aria-hidden="true"></i></a></th>
<th scope="col"><?php echo subject_sort_link('wr_scrap', $qstr2, 1) ?>스크랩 <i class="fa fa-sort" aria-hidden="true"></i></a></th>[/code]
이렇게 하니가 스크랩순으로 정렬이 안되던데 소스를 잘못 적용한건가영?