최근글 특정 게시물을 1개씩 바뀌게 하는 방법? 정보
그누보드 최근글 특정 게시물을 1개씩 바뀌게 하는 방법?본문
어제부터 하루종일 컴터 앞에서 앉아있다가 글을 띄웁니다..-.-;
배열이나 케이스문을 사용해야 되는 건가요? 게시물을 찾아봤는데, 비슷한 것들은 꽤 있더군요..
문제는 제가 응용능력이 없어서리...흑흑.. 더 열심히 해야되겠습니다..
최근글을 뽑는데요, 게시판에 글을 5개정도 넣고, 접속할 때마다 1개씩 반복되지 않게
바뀌면서 보여주는 건 어떻게 하는걸까요?
게시판에서 여러가지 글들을 찾아보았는데, 랜덤으로 하면 글이 반복되더라구여.. 예를 들어 5개의 글을 쓰면 2개만 반복됩니다...또 게시물을 5개 넘게 등록해야 랜덤되는 글들도 갯수가 많아지고..?요... 반복되지 않아야 하구요..
혹시 반복되지 않는 것이 불가능하다면... rand()함수를 이용해서 하는데 5개가 반복이 안되고 2개만 반복이 되는지... 궁금합니다.
고수님들의 답변 부탁드리겠습니다요~^^
좋은 하루 되세요~^^*
배열이나 케이스문을 사용해야 되는 건가요? 게시물을 찾아봤는데, 비슷한 것들은 꽤 있더군요..
문제는 제가 응용능력이 없어서리...흑흑.. 더 열심히 해야되겠습니다..
최근글을 뽑는데요, 게시판에 글을 5개정도 넣고, 접속할 때마다 1개씩 반복되지 않게
바뀌면서 보여주는 건 어떻게 하는걸까요?
게시판에서 여러가지 글들을 찾아보았는데, 랜덤으로 하면 글이 반복되더라구여.. 예를 들어 5개의 글을 쓰면 2개만 반복됩니다...또 게시물을 5개 넘게 등록해야 랜덤되는 글들도 갯수가 많아지고..?요... 반복되지 않아야 하구요..
혹시 반복되지 않는 것이 불가능하다면... rand()함수를 이용해서 하는데 5개가 반복이 안되고 2개만 반복이 되는지... 궁금합니다.
고수님들의 답변 부탁드리겠습니다요~^^
좋은 하루 되세요~^^*
댓글 전체
소스를 공개해야 편하게 보실 것 같아서요..
최근글에 적용한 만도님의 '최근글 랜덤하게 1개씩 보여주기' coolsite.zip 파일입니다... 문제가 멀까요? 제가 수정한 부분은 마지막쪽의 테이블 부분입니다.. 혹시 제가 수정한 부분이 랜덤이 안되는 인가여?
<?
/*
===============
사용가능 변수 설명
===============
<?=$bo_table?> // 테이블명
<?=$reldir?> // 상대경로
<?=$bbsdir?> // 상대경로
<?=$wr_subject?> // 게시물 제목
<?=$wr_date?> // 게시물 일시 (원본 : $row[wr_datetime])
<?=$a_list_link?> // 게시물 링크
*/
$mmdd = substr($wr_date, 3, 5);
$tg="target='_blank'";
//$lenth=33;//글내용 글자수 조정
//$wr_content = get_text(cut_str($row[wr_content], $lenth, '...'));
$thumbx = 64;
$thumby = 48;
// 이미지파일의 x, y 사이즈 계산하여 리턴
function mando2_image_size($x, $y, $thumbx, $thumby) {
if($x > $thumbx) {
$overx = ($x - $thumbx) / $x;
$x = $thumbx;
$y = intval($y - ($y * $overx));
}
if($y > $thumby) {
$overy = ($y - $thumby) / $y;
$y = $thumby;
$x = intval($x - ($x * $overy));
}
return array('x'=>$x, 'y'=>$y);
}
for($i=0; $i<count($list); $i++) {
$destfile = $list[$i][file_image1].'mandoThumb';
$size = getimagesize($list[$i][file_image1]);
if(is_array($size) && !is_file($destfile)) {
switch($size[2]) {
case(1) :
if(function_exists('ImageCreateFromGif')) $im = ImageCreateFromGif($list[$i][file_image1]);
break;
case(2) :
if(function_exists('ImageCreateFromJpeg')) $im = ImageCreateFromJpeg($list[$i][file_image1]);
break;
case(3) :
if(function_exists('ImageCreateFromPng')) $im = ImageCreateFromPng($list[$i][file_image1]);
break;
}
$fixsize = mando2_image_size($size[0], $size[1], $thumbx, $thumby);
if($im) {
if($i==0) @exec("rm ".dirname($_SERVER[SCRIPT_FILENAME])."/data/file/$bo_table/*mandoThumb -rf");
if(function_exists('ImageCreateTrueColor')) $newim = ImageCreateTrueColor($fixsize[x],$fixsize[y]);
else $newim = ImageCreate($fixsize[x],$fixsize[y]);
if(function_exists('ImageCopyResampled')) ImageCopyResampled($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
else ImageCopyResized($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
ImageDestroy($im);
ImageJpeg($newim, $destfile, 90);
ImageDestroy($newim);
unset($im, $newim);
}
$list[$i][img][x] = $fixsize[x];
$list[$i][img][y] = $fixsize[y];
} else {
if(is_file($destfile)) {
$size = getimagesize($destfile);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
} else {
$list[$i][file_image1] = "$latest_skin/noimg.gif";
$size = getimagesize($list[$i][file_image1]);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
}
}
if(is_file($destfile)) $list[$i][file_image1] = $destfile;
// if(time()-(60*60*24) = strtotime($list[$i][wr_datetime])) $list[$i][date] = date('H:i',strtotime($list[$i][wr_datetime]));
// else $list[$i][date] = date('Y.m.d',strtotime($list[$i][wr_datetime]));
}
?>
//이부분에서부터 바뀌야 할 것 같은데 잘 모르겠습니다.. 배열이나 케이스 문으로 바꾸면 될까요?
SQL에서 rand()로 바꿔주면 글이 바뀌긴 하는데 글을 9개정도 쓰면 5개정도 반복되구요, 5개정도 쓰면 2개정도 반복됩니다.
게시판에는 글을 5개정도만 남기고 5개가 접속시마다 바뀌게 하려고 하는 거거든요...-.-;
<table width="335" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="bbs/skin/latest/images/home/clients_say_top_bgline.gif" width="335" height="9"></td>
</tr>
<tr>
<td><table width="335" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="11"><img src="bbs/skin/latest/images/home/clients_say_left_bgline.gif" width="11" height="80"></td>
<td><table width="314" border="0" cellpadding="0" cellspacing="0">
<? for ($i=0; $i<count($list); $i++) { ?>
<tr>
<td><?=$list[$i][wr_content]?></td>
</tr>
<tr>
<td><div align="right">-<?=$list[$i][subject]?></div></td>
</tr>
<? } ?>
</table></td>
<td width="10"><img src="bbs/skin/latest/images/home/clients_say_right_bgline.gif" width="10" height="80"></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="bbs/skin/latest/images/home/clients_say_bottom_bgline.gif" width="335" height="5"></td>
</tr>
</table>
최근글에 적용한 만도님의 '최근글 랜덤하게 1개씩 보여주기' coolsite.zip 파일입니다... 문제가 멀까요? 제가 수정한 부분은 마지막쪽의 테이블 부분입니다.. 혹시 제가 수정한 부분이 랜덤이 안되는 인가여?
<?
/*
===============
사용가능 변수 설명
===============
<?=$bo_table?> // 테이블명
<?=$reldir?> // 상대경로
<?=$bbsdir?> // 상대경로
<?=$wr_subject?> // 게시물 제목
<?=$wr_date?> // 게시물 일시 (원본 : $row[wr_datetime])
<?=$a_list_link?> // 게시물 링크
*/
$mmdd = substr($wr_date, 3, 5);
$tg="target='_blank'";
//$lenth=33;//글내용 글자수 조정
//$wr_content = get_text(cut_str($row[wr_content], $lenth, '...'));
$thumbx = 64;
$thumby = 48;
// 이미지파일의 x, y 사이즈 계산하여 리턴
function mando2_image_size($x, $y, $thumbx, $thumby) {
if($x > $thumbx) {
$overx = ($x - $thumbx) / $x;
$x = $thumbx;
$y = intval($y - ($y * $overx));
}
if($y > $thumby) {
$overy = ($y - $thumby) / $y;
$y = $thumby;
$x = intval($x - ($x * $overy));
}
return array('x'=>$x, 'y'=>$y);
}
for($i=0; $i<count($list); $i++) {
$destfile = $list[$i][file_image1].'mandoThumb';
$size = getimagesize($list[$i][file_image1]);
if(is_array($size) && !is_file($destfile)) {
switch($size[2]) {
case(1) :
if(function_exists('ImageCreateFromGif')) $im = ImageCreateFromGif($list[$i][file_image1]);
break;
case(2) :
if(function_exists('ImageCreateFromJpeg')) $im = ImageCreateFromJpeg($list[$i][file_image1]);
break;
case(3) :
if(function_exists('ImageCreateFromPng')) $im = ImageCreateFromPng($list[$i][file_image1]);
break;
}
$fixsize = mando2_image_size($size[0], $size[1], $thumbx, $thumby);
if($im) {
if($i==0) @exec("rm ".dirname($_SERVER[SCRIPT_FILENAME])."/data/file/$bo_table/*mandoThumb -rf");
if(function_exists('ImageCreateTrueColor')) $newim = ImageCreateTrueColor($fixsize[x],$fixsize[y]);
else $newim = ImageCreate($fixsize[x],$fixsize[y]);
if(function_exists('ImageCopyResampled')) ImageCopyResampled($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
else ImageCopyResized($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
ImageDestroy($im);
ImageJpeg($newim, $destfile, 90);
ImageDestroy($newim);
unset($im, $newim);
}
$list[$i][img][x] = $fixsize[x];
$list[$i][img][y] = $fixsize[y];
} else {
if(is_file($destfile)) {
$size = getimagesize($destfile);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
} else {
$list[$i][file_image1] = "$latest_skin/noimg.gif";
$size = getimagesize($list[$i][file_image1]);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
}
}
if(is_file($destfile)) $list[$i][file_image1] = $destfile;
// if(time()-(60*60*24) = strtotime($list[$i][wr_datetime])) $list[$i][date] = date('H:i',strtotime($list[$i][wr_datetime]));
// else $list[$i][date] = date('Y.m.d',strtotime($list[$i][wr_datetime]));
}
?>
//이부분에서부터 바뀌야 할 것 같은데 잘 모르겠습니다.. 배열이나 케이스 문으로 바꾸면 될까요?
SQL에서 rand()로 바꿔주면 글이 바뀌긴 하는데 글을 9개정도 쓰면 5개정도 반복되구요, 5개정도 쓰면 2개정도 반복됩니다.
게시판에는 글을 5개정도만 남기고 5개가 접속시마다 바뀌게 하려고 하는 거거든요...-.-;
<table width="335" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="bbs/skin/latest/images/home/clients_say_top_bgline.gif" width="335" height="9"></td>
</tr>
<tr>
<td><table width="335" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="11"><img src="bbs/skin/latest/images/home/clients_say_left_bgline.gif" width="11" height="80"></td>
<td><table width="314" border="0" cellpadding="0" cellspacing="0">
<? for ($i=0; $i<count($list); $i++) { ?>
<tr>
<td><?=$list[$i][wr_content]?></td>
</tr>
<tr>
<td><div align="right">-<?=$list[$i][subject]?></div></td>
</tr>
<? } ?>
</table></td>
<td width="10"><img src="bbs/skin/latest/images/home/clients_say_right_bgline.gif" width="10" height="80"></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="bbs/skin/latest/images/home/clients_say_bottom_bgline.gif" width="335" height="5"></td>
</tr>
</table>
죄송합니다. 저한테 쪽지 주셨던데...
제가 위의 사항은 잘 몰라서요...저도 그누보드 초보자랍니다.
잘 해결되시길...^^
제가 위의 사항은 잘 몰라서요...저도 그누보드 초보자랍니다.
잘 해결되시길...^^