그룹으로 뽑아오는 최근 게시물인데요.
랜덤으로 돌리려고 하면 어찌해야 할까요?
<?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;}/// 함수 정의 끝 ?>
답변 4개 / 댓글 2개
컴이 고장나서 며칠 접속을 못했습니다. ㅜ.ㅜ
위에 링크된 스킨이 맞다면, 이상없이 될텐데요..
제가 관리하는 사이트에서 테스트 해보니 정상 출력이 되거든요..
위의 스킨을 다운로드 하여,
/lib/ 에 latest_group.lib.php 를 올리고,
/skin/latest/ngallery를 통째로 올리고,
php 파일을 이렇게 만들어서,
<?
include_once("./_common.php");
$g4['title'] = "";
include_once("$g4[path]/head.php");
include_once "$g4[path]/lib/latest_group.lib.php";
?>
<?=latest_group("ngallery","그룹명","5","제목")?>
<?
include_once("./_tail.php");
?>
그누보드 폴더에 넣고 불러 오니, 정상적으로 작동합니다.
한번 확인해 보세요..^^
그래도 안되면, 에러나는 주소를 알려주시면 같이 보도록 하지요..^^
44번 내용을
$sql .= " order by rand()";
이렇게 하시면, 아예 오류가 없을것 같네요.
답변에 대한 댓글 1개
44번 째 줄에 ";"이 두번 들어갔거나, 없는 경우 입니다
php 문법에서 한 줄의 끝에는 항상 ; 으로 마무리 됩니다.
; 가 꼭 마지막에 한번 들어가야 합니다.
44번째 줄에 있는
$sql .= (!$orderby) ? " order by wr_hit desc " : " order by wr_id desc ";
이 내용을
$sql .= (!$orderby) ? " order by rand()";
이렇게 바꾸면 될 겁니다.
답변에 대한 댓글 1개
Parse error: syntax error, unexpected ';' in /home/hosting_users/dew_tongil/www/lib/latest_group.lib.php on line 44
이런 에러가 나오는데 해결 방법이있을까요?
답변을 작성하려면 로그인이 필요합니다.
이제는 사이트가 뜨는데
이런 에거가 뜨네요.
산넘어 산이네요. ^^;;
select * from g4_write_tongil04_a where wr_is_comment = 0 order by rand() limit 10
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' limit 10' at line 1
error file : /index-new.php