무

최신글 이미지만 랜덤으로 뽑아오게 하려면

아래는 오기님의 최신게시물입니다.
이미지와 최신글이 나오는 스킨입니다.

질문이 두개입니다.

1. 여기서 이미지의 경우만 랜덤으로 뽑아 오게 하려면 어떤 소스를 적용해 주어야 할까요?
도움주실분 계시면 좀 도와 주셔요.


http://www.sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=61215&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%B3%D7%C0%CC%B9%F6&sop=and&page=5

==========================================================

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

  $sql="select a.wr_id,a.wr_subject,b.bf_file from g4_write_$bo_table as a, g4_board_file as b where";
  $sql.=" b.bo_table='$bo_table' and (a.wr_id=b.wr_id and b.bf_no='0' and a.wr_is_comment='0') order by a.wr_id desc limit 1";
  $rs = mysql_query($sql);
  if($rs) {
  $data = mysql_fetch_array($rs);

$img_width = "95";  //썸네일 가로길이
$img_height = "60"; //썸네일 세로길이
$img_quality = "80"; //이미지 질
$img_text = "12"; //썸네일 제목 길이

if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");

$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumbLatest';

@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);

 $thumb = $thumb_path.'/'.$data[wr_id];
      if (!file_exists($thumb)) {
        $file = $data_path .'/'. $data[bf_file];
        if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
            $size = getimagesize($file);
            if ($size[2] == 1)
                $src = imagecreatefromgif($file);
            else if ($size[2] == 2)
                $src = imagecreatefromjpeg($file);
            else if ($size[2] == 3)
                $src = imagecreatefrompng($file);
            else
                break;

            $rate = $img_width / $size[0];
            $height = (int)($size[1] * $rate);
            if ($height < $img_height)
                $dst = imagecreatetruecolor($img_width, $height);
            else
                $dst = imagecreatetruecolor($img_width, $img_height);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
            imagejpeg($dst, $thumb_path.'/'.$data[wr_id], $img_quality);
            chmod($thumb_path.'/'.$data[wr_id], 0606);
        }
    }

  if (file_exists($thumb))
        $view_img = "<a href='./$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id=$data[wr_id]'><img src='$thumb' width='$img_width' height='$img_height' border='0'></a>";

 $w_subject = "<a href='./$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id=$data[wr_id]'>".mb_substr($data[wr_subject],0,$img_text,"euc_kr")."</a>";
  }

 $th_day=date("w");
  switch($th_day){
  case "0":
  $td="일";
  break;
  case "1":
  $td="월";
  break;
  case "2":
  $td="화";
  break;
  case "3":
  $td="수";
  break;
  case "4":
  $td="목";
  break;
  case "5":
  $td="금";
  break;
  case "6":
  $td="토";
  break;
  }
?>

<table width="412" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="61" height="25" align="center" style="color:black;font-weight:bold"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font color="black"><strong><?=$board[bo_subject]?></strong></font></a> <img src='<?=$latest_skin_path?>/img/ic-news.gif' align=absmiddle> </td>
  <td colspan="2"><span style='font-family:돋움; font-size:8pt; color:#00000;'><?=$today=date("n. j. [$td]");?></span></td>
    <td width="63" align="center"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/ic-view.gif' align=absmiddle border="0"></a></td>
  </tr>
  <tr><td colspan=4 bgcolor=#EBEBEB height=1></td></tr>
  <tr>
    <td height="102" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="123" height="80" align="center"><?=$view_img?></td>
    </tr>
      <tr>
        <td height="31" align="center" valign="top">[<?=$w_subject?>]</td>
  </tr>
    </table>
    </td>
    <td colspan="2" valign="top">
 <table width="100%" border="0" cellpadding="0" cellspacing="0">
<? for ($i=0; $i<count($list); $i++) { ?>
<tr>
    <td colspan=4 align=center>
        <table width=95%>
        <tr>
            <td height=17><img src='<?=$latest_skin_path?>/img/dot.gif' align=absmiddle>  
            <?
            echo $list[$i]['icon_reply'] . " ";
            echo "<a href='{$list[$i]['href']}'>";
            if ($list[$i]['is_notice'])
                echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list[$i]['subject']}</strong></font>";
            else
                echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list[$i]['subject']}</font>";
            echo "</a>";

            if ($list[$i]['comment_cnt'])
                echo " <a href=\"{$list[$i]['comment_href']}\"><span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list[$i]['comment_cnt']}</span></a>";
            /*
            if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
            if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }

           echo " " . $list[$i]['icon_new'];
           echo " " . $list[$i]['icon_file'];
           echo " " . $list[$i]['icon_link'];
           echo " " . $list[$i]['icon_hot'];
           echo " " . $list[$i]['icon_secret'];
     */
            ?></td></tr>
        <!--<tr><td bgcolor=#EBEBEB height=1></td></tr>-->
        </table></td>
</tr>
<? } ?>

<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>
    </table></td>
  </tr>
 
  <tr>
    <td height="0"></td>
    <td width="62"></td>
    <td width="229"></td>
    <td></td>
  </tr>
</table>

댓글 2개

sql ..... order by a.wr_id desc limit 1";

--> a.wr_id 여기를 rand()로 하면 랜덤으로 나오기는 하는데요...
하하 너무 감사합니다.
덕분에 잘 적용했습니다.
늘 행복하셔요 ^^
댓글을 작성하시려면 로그인이 필요합니다.

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
09-12-20 조회 1,640
09-12-20 조회 4,620
09-12-20 조회 1,058
09-12-20 조회 1,920
09-12-20 조회 1,586
09-12-20 조회 1,030
09-12-20 조회 1,607
09-12-20 조회 1,525
09-12-20 조회 1,794
09-12-20 조회 1,287
09-12-20 조회 1,233
09-12-20 조회 1,628
09-12-20 조회 1,326
09-12-20 조회 1,638
09-12-20 조회 2,266
09-12-19 조회 1,246
09-12-19 조회 2,083
09-12-19 조회 1,627
09-12-19 조회 996
09-12-19 조회 1,156