채택완료

board_new_table 에서 글제목, 글쓴이, 날짜 불러오기

2017-07-27 (목) 13:40:14 2,310

new_main.php

Copy
<?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'].'&amp;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&amp;view=$view&amp;mb_id=$mb_id&amp;page=");include_once($new_skin_path.'/new.skin.php');?>

new.skin.php

Copy
<?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_datetime2'])); ?> </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 ?><!-- } 전체게시물 목록 끝 -->

5e82bb4f667c014c989f6ae24f787efd_1501130357_0983.png

지금 날짜도 이상하게 나오고 글제목이랑 이름은 아예 나오지도 않네요 ㅠㅠ

게시판 이름만 제대로 나오는게 어디가 어디부터 잘못된건지 알수가 없네요 ㅠ
 

|

답변 1개 / 댓글 5개

채택된 답변
+20 포인트

이상이 있다고 올려주신 두개의 파일로

경로만 조절하고 

나머지 소스는 그대로 제가 테스트 해봤습니다만

http://gboard.deb.kr/test/main.php

에서보시면 

제목 / 이름 / 일자 

다 정상적으로 잘 나옵니다.

변경한것은

스킨소스에서

일자부분에서

Copy
<td class="td_date"><?php echo date("Y-m-d", strtotime($list[$i]['wr_datetime'])); ?> </td>

와 같이 변경했습니다.

Y 대문자

wr_datetime2 => wr_datetime

답변에 대한 댓글 5개

index 부분도 볼수있을까요?
@꼬마새벽
index.php 는 없습니다.

그냥 main.php 1개
main.skin.php 1개
로 구성해서
위에 보이는 URL로 뿌린겁니다.
index.php 에서
include_once(G5_BBS_PATH.'/new_main.php');
로 접근하는데 안되서요...
@꼬마새벽

개발하실때
new_main.php
파일을
/bbs/ 하위에 넣으셨나요?

스킨디렉토리명을
new_main.php 파일에 스킨디렉토리를 적으신것 같이
[code]
$new_skin_path = G5_SKIN_PATH.'/new/main'; // 스킨절대경로
$new_skin_url = G5_SKIN_URL.'/new/main'; // 스킨경로
[/code]

그리고, 스킨파일은 /skin/new/main/ 하위에 있는지 확인해보세요

index.php 에서
헤더같은것을 막고 불러보세요

오류가 나올만한것을 막고나서 필요한내용이 정상적으로 보이는지가 먼저 중요해 보이네요
파일은 경로안에 잘 있습니다.

답변을 작성하려면 로그인이 필요합니다.