답변 3개
채택된 답변
+20 포인트
8개월 전
/lib/latest.lib.php를 활용하여
원하는 게시판 목록을 최신글 형태로 불러오면 어쩔까요.
. . .
아~, list.skin.php에서 구현된 특정한 리스트만 write.skin.php 하단에 불러오자면~ latest() 함수를 이용하지 않고 기존 list.skin.php의 로직을 포함한 별도의 파일로 분리한 뒤
이를 write.skin.php에 include하시면~~~
로그인 후 평가할 수 있습니다
답변에 대한 댓글 2개
a
alexseo
8개월 전
g
glitter0gim
8개월 전
해당 게시판 테이블(g5_write_게시판)에서 원하는 조건으로
직접 SQL 쿼리를 통해 게시물을 조회한 후, 그누 내장 함수(get_text, cut_str)를 이용하여
제목, 작성자, 조회수, 날짜 등의 필드를 HTML 테이블로 출력하시면~
PHP를 사용하여 데이터베이스에서 직접 쿼리한 결과를 PHP, HTML 구조의
코드를 만들어 봤습니다. 프롬프트를 잘 넣었는지는 확인 않됐습니다.
write.skin.php 하단부에 추가해 보실래요.[code]
<!-- 특정 게시판의 목록을 직접 쿼리로 불러오기 -->
<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>
[/code]
직접 SQL 쿼리를 통해 게시물을 조회한 후, 그누 내장 함수(get_text, cut_str)를 이용하여
제목, 작성자, 조회수, 날짜 등의 필드를 HTML 테이블로 출력하시면~
PHP를 사용하여 데이터베이스에서 직접 쿼리한 결과를 PHP, HTML 구조의
코드를 만들어 봤습니다. 프롬프트를 잘 넣었는지는 확인 않됐습니다.
write.skin.php 하단부에 추가해 보실래요.[code]
<!-- 특정 게시판의 목록을 직접 쿼리로 불러오기 -->
<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>
[/code]
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
해당 게시판 리스트에서
쿼리로 불러오고 싶습니다.