그룹으로 뽑아오는 최근 게시물인데요.
이걸 그룹의 각 게시판의 최신글 1가지 씩만 가지고 나오고 싶은데
가능할까요?
Copy
<?if (!defined('_GNUBOARD_')) exit; function latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $no_table="", $category="", $orderby=""){ global $config; global $g4; $list = array(); $limitrows = $rows; $sqlgroup = " select bo_table, bo_subject,bo_9 from $g4[board_table] where gr_id = '$gr_id' $sqls "; // 제거할 테이블들 if ($no_table) { $t_flag = serialize($no_table); if ($t_flag[0] == "a") { //Array이면 for ($ic=0; $ic<count($no_table); $ic++) { $sqlgroup .= " and bo_table != '$no_table[$ic]' "; } } else if ($t_flag[0] == "s") { //String이면 $sqlgroup .= " and bo_table != '$no_table' "; } } $sqlgroup .= " and bo_use_search=1 order by bo_order_search "; $rsgroup = sql_query($sqlgroup); if ($skin_dir) $latest_skin_path = "$g4[path]/skin/latest/$skin_dir"; else $latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]"; for ($j=0, $k=0; $rowgroup=sql_fetch_array($rsgroup); $j++) { $bo_table = $rowgroup[bo_table]; // 테이블 이름구함 $sql = " select * from {$g4[board_table]} where bo_table = '$bo_table' "; $board = sql_fetch($sql); $tmp_write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 실제이름 // 옵션에 따라 정렬 $sql = "select * from $tmp_write_table where wr_is_comment = 0 "; // $sql .= "and wr_datetime > ( now() - interval 512 hour) "; $sql .= (!$category) ? "" : " and ca_name = '$category' "; $sql .= (!$orderby) ? " order by wr_hit desc " : " order by wr_id desc "; $sql .= " limit $limitrows"; $result = sql_query($sql); for ($i=0; $row = sql_fetch_array($result); $i++, $k++) { if(!$orderby) $op_list[$k] = $row[wr_datetime]; else { $op_list[$k] = is_string($row[$orderby]) ? sprintf("%-256s", $row[$orderby]) : sprintf("%016d", $row[$orderby]); $op_list[$k] .= $row[wr_datetime]; } $list[$k] = get_list($row, $board, $latest_skin_path, $subject_len); $list[$k][bo_table] = $board[bo_table]; $list[$k][bo_subject] = $board[bo_subject]; $list[$k][bo_wr_subject] = cut_str($board[bo_subject] . $list[$k][wr_subject], $subject_len); } } if($k>0) array_multisort($op_list, SORT_DESC, $list); if($k>$rows) array_splice($list, $rows); ob_start(); include "$latest_skin_path/latest.skin.php"; $content = ob_get_contents(); ob_end_clean(); return $content;}/// 함수 정의 끝 ?>
답변 2개 / 댓글 2개
채택된 답변
+20 포인트
2015-05-06 (수) 14:52:15
function latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $no_table="", $category="", $orderby="")
$rows = 10 <-- 각 게시판별로 10개씩 구해 오게 되어 있습니다. 숫자를 조절하시면 됩니다.
답변에 대한 댓글 1개
2015-05-07 (목) 12:59:45
2015-05-06 (수) 20:11:26
<? echo latest_group('스킨','그룹아이디', 1, ~~~~);?> <----여기에 1
답변에 대한 댓글 1개
2015-05-07 (목) 13:00:49
답변 감사합니다.
그룹별 각각의 게시판에서 뽑아 나와야 하는데
1로 하면 그룹의 최신글 딱 하나만 나오더라구요.
그룹별 각각의 게시판에서 뽑아 나와야 하는데
1로 하면 그룹의 최신글 딱 하나만 나오더라구요.
답변을 작성하려면 로그인이 필요합니다.
1로 수정했는데 같은 게시판의 이미지가 2~3개 나올 때가 있더라구요.