ITmembers.net 아카이브 · 2002–2009

질문과 답변

[re] 제로보드에서..

두리뭉실님이 지적하신대로 하면 되구요...

만약 메인페이지에서 최근 한달간의 게시물을 보기 위한 버튼을 만들었다면,
그 버튼에 최근 한달 게시물 불러오는 php 파일 링크를 걸어주면 되겠죠.
예를 들어 메인페이지에서

<a href=month.php>최근 한달 게시물 보기</a> 이렇게 하면 되겠죠...

그리고
month.php는 아래와 같이 만들면 됩니다.

<?
///////////////////////////////////////////////////////////////////////
// 문자열 끊기 (이상의 길이일때는 … 로 표시)
//////////////////////////////////////////////////////////////////////

function cut_str($msg,$cut_size) // 글자를 원하는 길이만큼 잘라오는 함수
        {
                if($cut_size<=0) return $msg;
                if(ereg("\[re\]",$msg)) $cut_size=$cut_size+4;
                for($i=0;$i<$cut_size;$i++) if(ord($msg[$i])>127) $han++; else $eng++;
                $cut_size=$cut_size+(int)$han*0.6;
                $point=1;
                for ($i=0;$i<strlen($msg);$i++)
                        {
                                if ($point>$cut_size) { return $pointtmp."…";}
                                if (ord($msg[$i])<=127)
                                        {
                                                $pointtmp.= $msg[$i];
                                                if ($point%$cut_size==0) { return $pointtmp."…"; }
                                        }
                                else
                                {
                                        if ($point%$cut_size==0) { return $pointtmp."…"; }
                                        $pointtmp.=$msg[$i].$msg[++$i];
                                        $point++;
                                }
                                $point++;
                        }
                return $pointtmp;
        }

function new_list($id, $num, $max)
        { // $id : 웹보드 이름을 정의, $num : 몇 개의 게시물을 추출할 것인지 정함, $max : 몇 글자까지 보여줄건지 결정

//                $list_count=0; //표시할 게시물 목록수(내가 넣은 거)... 마지막에 <br>태그 안넣기 위해...

                $dir="제로보드설치디렉토리";  // 이건 그냥 지정해 주세요 그게 제일 편합니다.  htttp://www.itmembers.net/bbs 와 같이
                $connect=mysql_connect("localhost","ID","PW"); //호스트, usr ID, PW
                mysql_select_db("XXXXXXX"); //DB이름

                $beforemonth=strtotime("-1 month"); // 한달 전 타임스탬프를 구합니다.

                $result=mysql_query("select * from zetyx_board_$id where reg_date > $beforemonth order by no desc limit $num");

          // 웹보드 이름을 $id로 주고 추출할 게시물의 수를 $num 으로 주었죠.. 매개 변수의 값을 그대로 사용한다는 뜻입니다.

                while($data=mysql_fetch_array($result))
                        {
                                $data[total_comment] = stripslashes($data[total_comment]); //간단한 답글 수
                                $data[subject] = stripslashes($data[subject]); //제목
                                $data[subject]=cut_str($data[subject], $max); // 제목의 길이를 $max 이내로 잘라서 다시 $data[subject]안에 넣어줍니다.

                                echo "<a href=$dir/view.php?id=$id&no=$data[no] onfocus=blur() class=link1>$data[subject]</a>"  ;
                                if($data[total_comment]) { echo"<font style=font-size:6pt>[$data[total_comment]]</font>"; } //댓글있으면, 댓글 개수 표시
                                echo "<br>";
                                }
        }

?>

<html>
<head></head>
<body>
<?
new_list('freeboard', 50,50) ;
?>
</body>
</html>

댓글 3