묻고답하기

게시판 질문입니다.

2004.12.19 00:04

전영환

=======================================================================================================
제가 만드는 게시판...
=======================================================================================================
<?
include"db_info.php";
session_start();
//strlen()
        if( isset($_SESSION["IS_READ"]) ) {  // 쿠키가 이미 설정된 경우
                $value = $_SESSION["IS_READ"];
                $pre = "_" . $no;
                if( !eregi( $pre , $value ) ) {  // 중복 인가 아닌가를 체크 , 없으면
                        $value = $value . $pre;
                        $_SESSION["IS_READ"] = $value;
                        mysql_query("UPDATE $board SET hit=hit+1 WHERE no='$no' LIMIT 1");
                }
        }
        else {   // 초기에 쿠키를 설정하는 경우
                $value = "_" . $no;
                $_SESSION["IS_READ"]=$value;
                mysql_query("UPDATE $board SET hit=hit+1 WHERE no='$no' LIMIT 1");
        }

if(isset($_COOKIE["IS_READ"])){ //쿠키가 설정된경우
        $value=$_COOKIE["IS_READ"];
        $pre="_".$no;
        if(!eregi($pre,$value)){ //쿠키 중복값채크 없으면 실행
        $value .=$value.$pre;
        SetCookie("IS_READ",$value,time()+60*60,"/");
        mysql_query("UPDATE $board SET hit=hit + 1 WHERE no ='$no' LIMIT 1");
        }
}else{        //최초구키 설정
        $value ="_".$no;
        SetCookie("IS_READ",$value,time()+60*60,"/");
        mysql_query("UPDATE $board SET hit=hit + 1 WHERE no ='$no'+ '+ ' LIMIT 1");
}

        $query="SELECT * FROM $board WHERE no='$no' LIMIT 1";
        $result=mysql_query($query,$con);
        $row=mysql_fetch_array($result);
        $name=stripslashes($row[name]);
        $email=stripslashes($row[email]);
        if($email) $name="<a href='mailto:$email'>".$name."</a>";
        $filename = $row[filename];
        $download = $row[download];
        $home=stripslashes($row[home]);
        $title=stripslashes($row[title]);
        $memo=nl2br(stripslashes($row[memo]));
        $wdate=$row[wdate];
        $wdate=date("Y_m_d",$wdate)." / ".date("h:i:s에 작성)",$wdate);
        $hit=$row[hit];
        $ip=$row[ip];
        $filename=$row[filename];
        $download=$row[download];
        $thread=$row[thread];
?>
<html>
<center>
<head>
<meta http-equiv='content-type' content='text/html; charset=euc-kr'>
<LINK rel='stylesheet' href='style.css' type='text/css'>
<title>글읽기</title>
</head>

<body bgcolor='white' text='black' link='blue' vlink='purple' alink='red'>
<table width='782' border='0' cellspacing='0'+ ' cellpadding='0' class='text_01'>
  <tr>
   <td rowspan='3' width='50'> </td>
   <td height='20'></td>
  </tr>
  <tr>
   <td>
    <table width='100%' border='0' cellspacing='1' cellpadding='0' bgcolor='dddddd'>
     <tr>
      <td bgcolor='fafafa' height='80' valign='top'>
       <table width='100%'+ ' border='+ '0' cellspacing='0' cellpadding='0'>
        <tr>
         <td height='80' width='160' valign='top'><img src='img/top_community01.gif' width='160' height='80'></td>
         <td height='80' width='10'></td>
         <td height='80' valign='top'>
          <table width='100%' border='0' cellspacing='0' cellpadding='10'>
           <tr>
            <td height='80' valign='top'>
             <table width='100%' border='0' cellspacing='1' cellpadding='10' height='60' bgcolor='eeeeee' class='text_01'>
              <tr>
               <td bgcolor='#FFFFFF' valign='top'> <p>글 읽기</p>
               </td>
              </tr>
             </table>
            </td>
           </tr>
          </table>
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
   </td>
  </tr>
  <tr>
   <td><p> </p>
                                <table width='100%' border='0' cellspacing='0' cellpadding='0' class='text_01' align='center'>
                                        <tr>
                                                <td height='3' background='./img/bg_view_top2.gif' colspan='4'></td>
                                        </tr>
                                        <tr>
                                                <td align='right' height='1' colspan='4'></td>
                                        </tr>
                                        <tr>
                                                <td height='10' bgcolor='f2f2f2' colspan='2'></td>
                                                <td height='5' colspan='2'></td>
                                        </tr>
                                        <tr>
                                                <td align='right' height='10' bgcolor='f2f2f2' width='130'><b>이 름</b></td>
                                                <td width='10' height='10' bgcolor='f2f2f2'> </td>
                                                <td width='10' height='10'></td>
                                                <td height='10'>
                                                <?
                                                if($email)
                                                echo"<a href='mailto:$email'>";
                                                else
                                                echo"<a>";
                                                ?>
                                                <b><?=$name?></b></a></td>
                                        </tr>
                                        <tr>
                                                <td align='right' height='8' bgcolor='f2f2f2' colspan='2'></td>
                                                <td height='8' colspan='2'></td>
                                        </tr>
<?
        if($home)
        echo"
                                        <tr>
                                                <td align='right' height='10' bgcolor='f2f2f2'><b>홈페이지</b></td>
                                                <td height='10' bgcolor='f2f2f2'> </td>
                                                <td height='10'></td>
                                                <td height='10'><a href='$home' target='_blank'>$home</a></td>
                                        </tr>
                                        <tr>
                                                <td align='right' height='10' bgcolor='f2f2f2'><b>이-메일</b></td>
                                                <td height='10' bgcolor='f2f2f2'> </td>
                                                <td height='10'></td>
                                                <td height='10'><a href='$email' target='_blank'>$email</a></td>
                                        </tr>
                                        <tr>
                                                <td align='right' height='8' bgcolor='f2f2f2' colspan='2'></td>
                                                <td height='8' colspan='2'></td>
                                        </tr>";
        if($filename){
                 $fsize=filesize("./data/".$filename)/1024/1024;
                 $size=number_format($size1, "2", ".", ",");
        echo"
        <tr>
            <td align='+ 'right' height='10' bgcolor='f2f2f2'><b>첨부파일</b></td>
            <td height='10' bgcolor='f2f2f2'> </td>
            <td height='10'></td>
            <td height='10' class='text_03'><a href='download.php?no=$no&file=$filename'>$filename ($fsize MB)</a> - download : $download</td>
                  </tr>
                  <tr>
            <td align='+ 'right' height='8' bgcolor='f2f2f2' colspan='2'></td>
            <td height='8' colspan='2'></td>
    </tr>";
        }
?>
                                        <tr>
                                                <td align='right' height='10' bgcolor='f2f2f2'+ '><b>제 목</b></td>
                                                <td height='10' bgcolor='f2f2f2'> </td>
                                                <td height='10'></td>
                                                <td height='10'><?=$title?></td>
                                        </tr>
                                        <tr>
                                                <td align='right' height='10' bgcolor='f2f2f2' colspan='2'></td>
                                                <td height='10' colspan='2'></td>
                                        </tr>
                                        <tr>
                                                <td height='1' colspan='4'></td>
                                        </tr>
                                        <tr>
                                                <td background='./img/bg_view_top.gif' height='3' colspan='4'></td>
                                        </tr>
                                </table>
        <table width='100%' border='0' cellspacing='0' cellpadding='0' class='text_01' align='center' style='+ 'table-layout:fixed;'>
        <tr>
        <td height='20'></td>
        </tr>
        <tr>
        <td style='word-break:break-all'>
<?
        if($filename){
                if(eregi(".jpg|.gif",$filename))
                // 그림을 보여주거나 안보여주게 만드는 곳
                echo"<img src='./data/$filename' width='100%' hight='100%'>";
                                        }
                echo"$memo";        
?>
        </td>
        </tr>
        <tr>
        <td height='20' align='right'></td>
        </tr>
        <tr>
        <td height='20' align='right' class='text_04'>(시간 : <?=$wdate?></td>
        </tr>
        <tr>
        <td height='30' align='right'+ '> </td>
        </tr>
        </table>
        <table width='100%' border='0'+ ' cellspacing='0' cellpadding='0' align='center'>
        <tr>
        <td height='40' background='+ './img/bg_list_bottom.gif'><a href='list.php?page=<?=$page?>'><img src='./img/button_list.gif' width='81' height='40' border='0'></a>
<?
        $query=mysql_query("select no,thread from $board where thread > $thread order by thread asc limit 1", $con);
        $prev_id=mysql_fetch_array($query);

        if ($prev_id[no]) // 이전 글이 있을 경우
        {
        echo "<a href=read.php?no=$prev_id[no]&page=$page><img src='./img/button_pre_t.gif'  width='58' height='40' border='0'></a>";
        }
        else
        {
        echo "<img src='./img/button_pre_t.gif'  width='58' height='40' border='0'>";
        }
        // 현재 글보다 no 값이 작은 글 중 가장 큰 것의 id를 가져온다. 바로 다음 글
        $query=mysql_query("select no from $board where thread < $thread order by thread desc limit 1", $con);
        $next_id=mysql_fetch_array($query);

        if ($next_id[no])
        {
        echo "<a href=read.php?no=$next_id[no]&page=$page><img src='./img/button_next_t.gif' width='58'+ ' height='40' border='0'></a>";
        }
        else
        {
        echo "<img src='./img/button_next_t.gif' width='58' height='40' border='0'>";
        }
?>
        </td>

                <td height='40' background='./img/bg_list_bottom.gif' align='right'><a href='reply.php?no=<?=$no?>&page=<?=$page?>'><img src='./img/button_reply.gif'  width='58' height='40' border='0'></a><a href='modify.php?no=<?=$no?>&page=<?=$page?>'><img src='./img/button_modify.gif' width='50' height='40' border='0'></a><a href='delete.php?no=<?=$no?>&page=<?=$page?>'><img src='./img/button_delete.gif' width='50' height='40' border='0'></a>
        </tr>
        </table>
<?
        $com = mysql_query("SELECT * FROM cecomment WHERE parent='$no' ORDER BY no DESC;");
        $total=mysql_num_rows($com);
        while($comrow=mysql_fetch_array($com,$con)){
        //for($i=0 ; $i<$total ; $i=$i+1) {
//                $comrow=mysql_fetch_array($com);
                $cmt_no=$comrow[no];
                $name = $comrow[name];
                $name = stripslashes($name);
                $memo = $comrow[memo];
                $memo = stripslashes($memo);
                $memo = str_replace(" "," ",$memo);
                $memo = nl2br($memo);
                $wdate = $comrow[wdate];
                $wdate=date("Y_m_d",$wdate)." / ".date("h:i:s",$wdate);
                $ip=$comrow[ip];
                                
        echo("<table width='100%' border='0' cellspacing='0' cellpadding='0' class='+ 'text_01' align='center'>
        <tr>
        <td colspan='10' height='15'></td>
        </tr>
        <tr>
        <td width='80' valign='top'>
        <b><a href='#'>$name</a></b></td>
        <td width='10' valign='top'></td>
        <td width='1'+ ' valign='top' bgcolor='F2F2F2'></td>
        <td width='10' valign='top'></td>
        <td width='15' valign='top'>::</td>
        <td valign='top' style='word-break:break-all'>$memo</td>
        <td valign='top' width='10'></td>
        <td valign='top' width='1' bgcolor='F2F2F2'></td>
        <td valign='top' width='10'></td>
        <form action='cmt_del.php?no=$no' name='cmt_del_form' method='post'+ '>
        <td valign='top' width='120' class='text_04'>$wdate
        <input type='hidden' name='cmt_no' value='$cmt_no'>
        <input type='image' border='0' name='cmt_del_img' src='./img/icon_delete.gif' width='16' height='14' align='absmiddle'>
        </td>
        </form>
        </tr>
        <tr>
        <td colspan='10' height='15'></td>
        </tr>
        <tr bgcolor='E0E0E0'>
        <td colspan='10' height='1'+ '></td>
        </tr>
        </table>");
         }
?>        
        
        <table width='100%' border='0' cellspacing='0'+ ' cellpadding='0' class='text_01' align='center'>
        <form action='cmt_ok.php?no=<?=$no?>' name='writeForm' method='post'>
        <!-- 삭제하면 안되요.. -->
        <input type='hidden' name='no' value='<?=$no?>'>
        <tr>
        <td colspan='2' height='10'+ '></td>
        </tr>
        <tr>
        <td>
        <table width='100%' border='0' cellspacing='0' cellpadding='0' class='text_01'+ '>
        <tr>
        <td width='140'>
        이름
        <input type='text'+ ' name='name' class='textarea_01' size='15' value=''>
        </td>
        <td>
        비밀번호
        <input type='password' name='pass' class='textarea_01' size='15'>
        </td>
        </tr>
        </table>
        </td>
        <td> </td>
        </tr>
        <tr>
        <td colspan='2' height='10'></td>
        </tr>
        <tr>
        <td>
        <textarea name='memo' class='textarea_01' style='width:100%; height:60px'></textarea>
        </td>
        <td align='right' width='70'>
        <input type='image' border='0' name='imageField3' src='./img/button_cwrite.gif' width='60' height='60' align='middle'>
        </td>
        </tr>
        </form>
        </table>
</td>
</tr>
</table>
</body>
</center>
</html>
=======================================================================================================
이전과 다음은 리스트 페이지에서 불러오도록 만들었습니다.
한가지 모르는것이 있는데
현재 페이지인 read.php에서 게시물들을 읽고나서 목록보기인 bg_list_bottom.gif를 누르면 가장 처음에 읽은
페이지로 넘어가게 됩니다.
가장 최근에 읽은 페이지로 넘어가게 하는 방법을 아시는 분들은 꼭 답변이나 메일을 주셨으면 합니다.
제가 모르는건 이것이니 꼭 답변 부탁드립니다.
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
이즈 마지막 ㅜㅜ 최근게시물.. [3] 2007.08.10
이대형 php 연동 한 화면에 선택한 그림 표현하기 질문 [2] 2007.08.10
천기 게시판에 성인광고가 계속해서 올라와요 [2] 2007.08.10
현호찬 게시판 문의  
이정훈 공지사항이나 게시판의 타이틀을 메인화면에 붙이고싶은데... [1] 2007.08.10
이정훈 공지사항이나 게시판의 글을 메인화면에 붙이고싶은데...  
손명수 플래쉬를 넣었는데... 급합니다 ㅡ.ㅜ [2] 2007.08.10
카타르시스 winapm이거좀알려주세요 [2] 2007.08.10
전영환 게시판 질문입니다.  
hansong 아시는분이면... 그냥지나가지말고.... 꼮~ 답변부탁이요  
페르디카 크기를...;; [1] 2007.08.10
Jenny Mysql3에서는 안났었는데 Mysql4에서 나는 인클루드오류? [3] 2007.08.10
이즈 최근게시물에서 스타일 시트 적용법..2번째;; [1] 2007.08.10
윤영필 ★apmsetup 이거 하나면 서버돌릴 수 있는 건가요? 하나? [3] 2007.08.10
레아.. 팝업 창을 띄우면 부모창이 지정된 주소로 이동되게 하는 방법... [1] 2007.08.10
이즈 최근게시물에 스타일 시트 적용방법좀 자세히좀 감사합니다.. [2] 2007.08.10
정영석 게시판 폰트가 이상해요~ 도와주세요~ 급해요... [3] 2007.08.10
새천년건강체조 폼메일과 관련해서 , (콤마) 문제; [1] 2007.08.10
예스님 벅스뮤직로고에 사용된 폰트 혹시 아는분 있나요 [1] 2007.08.10
호야 어떤 폰트인지 혹시 있으신분? [1] 2007.08.10
KillerMan 홈페이지 보고 답변좀 해주세요... 다른거 [1] 2007.08.10
김용묵 웹페이지에서 사용자컴퓨터에 있는 실행파일을 바로 실행하려고 합니다. [1] 2007.08.10
한용해 제작한 핸드폰 벨소리 다운로드 페이지 만드는 방법 있나요?  
너므조아 프레임에서 로그인할때 질문 있습니다. [1] 2007.08.10
김태정 아웃로그인 창이 깨집니다. -.-;;; [2] 2007.08.10
럭키러브 동영상 오른쪽 마우스를 막을수는 없나요? [3] 2007.08.10
현호찬 php문의 드립니다. [1] 2007.08.10
김민영 노프레임할때요.. [2] 2007.08.10
송대원 질문있는데요...(내용있습니다) [1] 2007.08.10
강지희 input type="text" 관련 질문입니다. [1] 2007.08.10