해당 게시판 테이블(g5_write_게시판)에서 원하는 조건으로
직접 SQL 쿼리를 통해 게시물을 조회한 후, 그누 내장 함수(get_text, cut_str)를 이용하여
제목, 작성자, 조회수, 날짜 등의 필드를 HTML 테이블로 출력하시면~
PHP를 사용하여 데이터베이스에서 직접 쿼리한 결과를 PHP, HTML 구조의
코드를 만들어 봤습니다. 프롬프트를 잘 넣었는지는 확인 않됐습니다.
write.skin.php 하단부에 추가해 보실래요.
<!-- 특정 게시판의 목록을 직접 쿼리로 불러오기 -->
<div class="tbl_head01 tbl_wrap">
<table>
<caption>게시판 목록</caption>
<thead>
<tr>
<th scope="col">번호</th>
<th scope="col">제목</th>
<th scope="col">작성자</th>
<th scope="col">조회</th>
<th scope="col">날짜</th>
</tr>
</thead>
<tbody>
<?php
$target_bo_table = '게시판아이디'; // 원하는 게시판 아이디
$target_write_table = $g5['write_prefix'] . $target_bo_table;
// 게시글 목록을 직접 쿼리로 불러오기
$sql = "SELECT * FROM {$target_write_table} WHERE wr_is_comment = 0 ORDER BY wr_datetime DESC LIMIT 0, 5";
$result = sql_query($sql);
// 목록 출력 반복문
for ($i = 0; $row = sql_fetch_array($result); $i++) {
$num = $i + 1;
$subject = get_text(cut_str($row['wr_subject'], 70));
$href = G5_BBS_URL.'/board.php?bo_table='.$target_bo_table.'&wr_id='.$row['wr_id'];
$writer = get_text($row['wr_name']);
$hit = number_format($row['wr_hit']);
$datetime = date('y.m.d', strtotime($row['wr_datetime']));
?>
<tr>
<td class="td_num"><?php echo $num; ?></td>
<td class="td_subject"><a href="<?php echo $href; ?>"><?php echo $subject; ?></a></td>
<td class="td_name"><?php echo $row['wr_name']; ?></td>
<td class="td_num"><?php echo $row['wr_hit']; ?></td>
<td class="td_datetime"><?php echo $row['wr_datetime']; ?></td>
</tr>
<?php } ?>
<?php if($i == 0) { ?>
<tr><td colspan="5" class="empty_table">게시물이 없습니다.</td></tr>
<?php } ?>
</tbody>
</table>
</div>