board_new_table 최신글 - 글제목, 글쓴이, 날짜 불러오기
index.php
include_once(G5_BBS_PATH.'/new_main.php');
new_main.php
<?phpinclude_once('./_common.php');$new_skin_path = G5_SKIN_PATH.'/new/main'; // 스킨절대경로$new_skin_url = G5_SKIN_URL.'/new/main'; // 스킨경로$rows = 8; // 목록수$sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b, {$g5['group_table']} c where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = 1 ";$gr_id = isset($_GET['gr_id']) ? $_GET['gr_id'] : "";if ($gr_id) { $sql_common .= " and b.gr_id = '$gr_id' ";}$view = isset($_GET['view']) ? $_GET['view'] : "";if ($view == "w") $sql_common .= " and a.wr_id = a.wr_parent ";else if ($view == "c") $sql_common .= " and a.wr_id <> a.wr_parent ";$mb_id = isset($_GET['mb_id']) ? strip_tags($_GET['mb_id']) : "";if ($mb_id) { $sql_common .= " and a.mb_id = '{$mb_id}' ";}$sql_order = " order by a.bn_id desc ";$sql = " select count(*) as cnt {$sql_common} ";$row = sql_fetch($sql);$total_count = $row['cnt'];$total_page = ceil($total_count / $rows); // 전체 페이지 계산if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)$from_record = ($page - 1) * $rows; // 시작 열을 구함$list = array();$sql = " select a.*, b.bo_subject, c.gr_subject, c.gr_id {$sql_common} {$sql_order} limit {$from_record}, {$rows} ";$result = sql_query($sql);for ($i=0; $row=sql_fetch_array($result); $i++) { $tmp_write_table = $g5['write_prefix'].$row['bo_table']; if ($row['wr_id'] == $row['wr_parent']) { // 원글 $comment = ""; $comment_link = ""; $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' "); $list[$i] = $row2; $name = get_sideview($row2['mb_id'], get_text(cut_str($row2['wr_name'], $config['cf_cut_name'])), $row2['wr_email'], $row2['wr_homepage']); // 당일인 경우 시간으로 표시함 $datetime = substr($row2['wr_datetime'],0,10); $datetime2 = $row2['wr_datetime']; if ($datetime == G5_TIME_YMD) { $datetime2 = substr($datetime2,11,5); } else { $datetime2 = substr($datetime2,5,5); } } else { // 코멘트 $comment = '<span class=new_comment>[코]</span> '; $comment_link = '#c_'.$row['wr_id']; $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_parent']}' "); $row3 = sql_fetch(" select mb_id, wr_name, wr_email, wr_homepage, wr_datetime from {$tmp_write_table} where wr_id = '{$row['wr_id']}' "); $list[$i] = $row2; $list[$i]['wr_id'] = $row['wr_id']; $list[$i]['mb_id'] = $row3['mb_id']; $list[$i]['wr_name'] = $row3['wr_name']; $list[$i]['wr_email'] = $row3['wr_email']; $list[$i]['wr_homepage'] = $row3['wr_homepage']; $name = get_sideview($row3['mb_id'], get_text(cut_str($row3['wr_name'], $config['cf_cut_name'])), $row3['wr_email'], $row3['wr_homepage']); // 당일인 경우 시간으로 표시함 $datetime = substr($row3['wr_datetime'],0,10); $datetime2 = $row3['wr_datetime']; if ($datetime == G5_TIME_YMD) { $datetime2 = substr($datetime2,11,5); } else { $datetime2 = substr($datetime2,5,5); } } $list[$i]['gr_id'] = $row['gr_id']; $list[$i]['bo_table'] = $row['bo_table']; $list[$i]['name'] = $name; $list[$i]['comment'] = $comment; $list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row2['wr_id'].$comment_link; $list[$i]['datetime'] = $datetime; $list[$i]['datetime2'] = $datetime2; $list[$i]['gr_subject'] = $row['gr_subject']; $list[$i]['bo_subject'] = $row['bo_subject']; $list[$i]['wr_subject'] = $row2['wr_subject'];}$write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, "?gr_id=$gr_id&view=$view&mb_id=$mb_id&page=");include_once($new_skin_path.'/new.skin.php');?>
new.skin.php
<?phpif (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가// 선택삭제으로 인해 셀합치기가 가변적으로 변함$colspan = 4;// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨add_stylesheet('<link rel="stylesheet" href="'.$new_skin_url.'/style.css">', 0);?><!-- 전체게시물 목록 시작 { --><div id="bo_list"><div class="tbl_head01 tbl_wrap"> <table> <thead> <tr> <th scope="col">게시판</th> <th scope="col">제목</th> <th scope="col">이름</th> <th scope="col">날짜</th> </tr> </thead> <tbody> <?php //echo '============================================================='; //print_r($list); //echo '============================================================='; for ($i=0; $i<count($list); $i++) { $num = $total_count - ($page - 1) * $config['cf_page_rows'] - $i; $bo_subject = mb_substr($list[$i]['bo_subject'],0,8,"utf-8"); // 게시판명 글자수 $wr_subject = get_text(cut_str($list[$i]['wr_subject'], 35)); // 게시물제목 글자수 ?> <tr> <td class="td_board"><a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $list[$i]['bo_table'] ?>"><?php echo $bo_subject ?></a></td> <td class="td_subject"><a href="./redirect.php?gr_id=<?php echo $list[$i]['gr_id'] ?>&bo_table=<?php echo $list[$i]['bo_table'];?>&wr_id=<?php echo $list[$i]['wr_id'];?>" onclick="return false;"><?php echo $list[$i]['comment'] ?><?php echo $wr_subject ?></a></td> <td class="td_name"><?php echo $list[$i]['wr_name'] ?></td> <td class="td_date"><?php echo date("y-m-d", strtotime($list[$i]['wr_datetime'])); ?> </td> </tr> <?php } ?> <?php if ($i == 0) echo '<tr><td colspan="'.$colspan.'" class="empty_table">게시물이 없습니다.</td></tr>'; ?> </tbody> </table></div></div><?php// echo $write_pages ?><!-- } 전체게시물 목록 끝 -->

index.php -> new_main.php -> new.skin.php 순으로 접근합니다.
new.skin.php
<td class="td_board"><a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $list[$i]['bo_table'] ?>"><?php echo $bo_subject ?></a></td> <td class="td_subject"><a href="./redirect.php?gr_id=<?php echo $list[$i]['gr_id'] ?>&bo_table=<?php echo $list[$i]['bo_table'];?>&wr_id=<?php echo $list[$i]['wr_id'];?>" onclick="return false;"><?php echo $list[$i]['comment'] ?><?php echo $wr_subject ?></a></td> <td class="td_name"><?php echo $list[$i]['wr_name'] ?></td> <td class="td_date"><?php echo date("y-m-d", strtotime($list[$i]['wr_datetime'])); ?>
를 보면 게시판 이름은 잘 불러오는 반면 글제목, 글쓴이명은 아예 못불러오고
날짜는 1970-01-01로 고정으로 계속 불러옵니다.
어떻게 고쳐야할까요?
답변 2개 / 댓글 2개
새글 저장과 출력은 어떤 게시판에 글을 등록하면 bbs폴더 > write_update.php 파일에 게시된 글과 함께 더불어 새글도 함께 등록됩니다.
저장된 디비 > 새글 테이블의 정보를 출력하게되죠.
질문글로 출력한 소스상 별 문제없는듯 싶구요.
디비 > g5_board_new 테이블을 살펴보세요.
그리고,
출력한 그림상 보면 g5_board_new 에 새글이 등록될 때 해당 게시물의 wr_id 값을 저장하지 못하는것 같네요..
wr_id 값이 없으면 정보가 없기 때문에 그림처럼 출력하지 않습니다.
$wr_subject 를 $lit[$i][wr_subject] 로 뿌려보시고 잘 나오면 그 위에 제목 글자수 줄이는 부분이 문제 있는것 같은데 한번 확인해보세요
답변에 대한 댓글 2개
답변을 작성하려면 로그인이 필요합니다.