전체 최신글 불러올때 특정값만 불러 오려 합니다.
본문
<?php
?>
$list = array();
$sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b where a.bo_table = b.bo_table and b.bo_use_search = 1 ";
$sql_common .= " and a.wr_id = a.wr_parent ";
$sql_order = " order by a.bn_id desc ";
$sql = " select a.*, b.bo_subject {$sql_common} {$sql_order} limit {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$tmp_write_table = $g5['write_prefix'].$row['bo_table'];
//원글
//$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_1 = 'Y' ");
$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");
$list[$i] = $row2;
// 당일인 경우 시간으로 표시함
$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);
}
$list[$i]['board_href'] = G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'];
$list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row2['wr_id'];
$list[$i]['subject'] = conv_subject($row2['wr_subject'], $subject_len, '…');
$list[$i]['datetime'] = $datetime;
$list[$i]['datetime2'] = $datetime2;
$list[$i]['bo_subject'] = $row['bo_subject'];
$list[$i]['wr_subject'] = $row2['wr_subject'];
}
for ($i=0,$count_list=count($list); $i<$count_list; $i++) {
?>
<li>
<div class="conts">
<!--a href="<?php echo $list[$i]['board_href']; ?>" class="board_name"><?php echo $list[$i]['bo_subject']; ?></a-->
<a href="<?php echo $list[$i]['href']; ?>" class="over">
<span class="board_title"><?php echo $list[$i]['subject']; ?></span>
<!--span class="board_hits"><?php echo $list[$i]['wr_hit']; ?></span-->
<span class="board_time"><?php echo $list[$i]['datetime2']; ?></span>
</a>
</div>
</li>
<?php
}
?>
-----------------------------------------------------------------------------
전체 최신글 소스
http://sir.co.kr/bbs/board.php?bo_table=g5_skin&wr_id=4565&sca=%EC%B5%9C%EC%8B%A0%EA%B8%80
extend폴더의 lib소스
<?php
?>
// board_new 게시판 최신글 추출
// $cache_time 캐시 갱신시간
function new_latest($skin_dir='', $rows=10, $subject_len=40, $cache_time=1, $options='')
{
global $g5;
//static $css = array();
if (!$skin_dir) $skin_dir = 'basic';
if(G5_IS_MOBILE) {
$latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
$latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
} else {
$latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
$latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;
}
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
---------------------------------------------------------------------------------------------
여기에서 여분필드 wr_1의 값이 Y 인것만 불러 오려 하는데 어떻게 해야 할지를 모르겠습니다.
빨간색 부분처럼 해 봤는데 잘 안되네요.
답변 1
$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' and wr_1 = 'y'");
이렇게 하시면 되겠습니다