RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR

<?
 // 테이블이름을 파라미터로 받는다.
 $pro_table = ( isset($HTTP_GET_VARS['table']) ? $HTTP_GET_VARS['table']  : 'board_list' );

 // 필요한 함수가 정의된 config.php를 include시킨다.
 include "config.php";

 // Mysql Server에 접속한다.
 $conn = mysql_pconnect( $set_host, $set_user, $set_password );
 mysql_select_db( $set_dbname );

 // 필요한 변수를 파라미터로 부터 정의한다.
 $pro_id  = ( isset($HTTP_GET_VARS['id'])  ? $HTTP_GET_VARS['id']     : 0 );
 $pro_field = ( isset($HTTP_GET_VARS['field']) ? strtolower($HTTP_GET_VARS['field']) : "title" );
 $pro_search = ( isset($HTTP_GET_VARS['search']) ? $HTTP_GET_VARS['search']    : NULL );
 $pro_start  = ( isset($HTTP_GET_VARS['start']) ? $HTTP_GET_VARS['start']    : 0 );

 // Search한 내용이 있는지 체크하여 쿼리에 반영한다.
 if ( $pro_search != NULL ){
  $condition = " where $pro_field like '%$pro_search%' ";  // 쿼리에 추가되는 부분
  $search_option = "&field=$pro_field&search=$pro_search";
 }
 $query = "select id, num, title, DATE_FORMAT(w_time,'%Y/%m/%d') as w_date, writer, lv, cnt from $pro_table $condition order by num desc, od asc, lv asc limit ".($pro_start*10).", $Title_Num ";
 
 // 쿼리를 날린다.
 $result = mysql_query ( $query );

 // 쿼리로부터 읽어온 결과를 차례로 뿌려준다.
 $num = @mysql_num_rows( $result );
 if ( $num > 0 ){ // 게시물이 존재할 경우
  for ( $i = 0; $i < $num ; $i++ ){
   $data = mysql_fetch_array( $result );
   $space = "&nbsp;";
   if ( $data[lv] > 0 ){ // 답글인 경우의 처리. 번호부분을 '+'로 바꾸고, 제목을 한칸씩 들여쓰기한다.
    $data[num] = "+";
    for ( $j=0; $j<$data[lv]; $j++ )
     $space .= "&nbsp;";
    $space .="@";
   }
   $LIST .=
"<tr bgcolor='#EFEFFF' height=20 align='center'>
 <td>$data[num]</td>
 <td align='left'>$space<a href='view.php?table=$pro_table&id=$data[id]&start=$pro_start$search_option' class='title'>".Stripslashes($data[title])."</a></td>
 <td>".Stripslashes($data[writer])."</td>
 <td>$data[w_date]</td>
 <td>$data[cnt]</td>
</tr>
";   // 결과와 링크를 결함하여 타이틀제목을 테이블 형태로 만든다.
  }
 }
 else {  // 게시물이 존재하지 않을 경우
  $LIST =
"<tr bgcolor='#EFEFFF' align='center'>
 <td colspan=5 height=200> <font color=blue>게시물이 존재하지 않습니다.</font></td>
</tr>
";
 }

 // 원하는 페이지로 바로 갈 수 있는 Short Cut을 만든다.
 $c_res = mysql_query ( "select count(id) as cid from $pro_table $condition "); // 전체 게시물 갯수를 읽어온다.
 $count = @mysql_result ( $c_res, 0, "cid" );  
 if ( $count > $Title_Num ){
  $end = ceil( $count / $Title_Num ); // 마지막 페이지 번호를 계산한다.
  for ( $i = 1; $i <= $end; $i++ ){
   if ( $i != $pro_start + 1 )
    $short_cut .= " [<a href='list.php?table=$pro_table&start=".($i-1).$search_option."'>$i</a>] ";
   else
    $short_cut .= " <b>[$i]</b> ";
  }
 }
 else
  $short_cut = " [1] ";

 // Short Cut의 개수가 정해놓은 개수 이상일 경우의 이전 Short Cut 리스트로 가기.
 if ( $pro_start >= $ShortCut_Num ){
  $prev_link = "<a href='list.php?table=$pro_table&start=".( floor($pro_start /     $ShortCut_Num) * $ShortCut_Num -10)."$search_option'> < </a>";

 }

 else
  $prev_link = " < ";
  $prev_link2 = "<a href='list.php?table=$pro_table&start=".(0)."$search_option'> << </a>";


// Short Cut의 개수가 정해놓은 개수 이상일 경우의 다음 Short Cut 리스트로 가기.
 if ( $count > ( $Title_Num * $ShortCut_Num ) ) {
  $next_link = "<a href='list.php?table=$pro_table&start=".( ceil($pro_start / $ShortCut_Num)   * $ShortCut_Num + 10)."$search_option'> > </a>";


    $next_link2 = "<a href='list.php?table=$pro_table&start=".($end-1).
    "$search_option'> >> </a>";
 }
   
   
   else{
    $next_link = " > ";
    $next_link2 = ">>";
   }


 // 사용한 Mysql Session을 닫는다.
 mysql_close();

 // Admin login 링크
 if ( auth() ){
  $admin_link ="<input type='button' name='admin' class='2daybutton' onclick=\"login=window.open('logout.php','_blank','width=300,height=150,scrollbars=no,menubar=no,resizable=no,status=no')\" value='Logout'> ";
 }
 else
  $admin_link ="<input type='button' name='admin' class='2daybutton' onclick=\"login=window.open('login.php','_blank','width=300,height=150,scrollbars=no,menubar=no,resizable=no,status=no')\" value='Login'> ";

 // HTML Code 를 출력한다.
 echo "<html>
  <head>
   <title> Board </title>
   <style>
    a:active ,a:link ,a:visited { font-size:9pt; color:black; text-decoration:none; }
    a.title:active ,a.title:link  { font-size:9pt; color:black; text-decoration:none; }
    a.title:visited    { font-size:9pt; color:green; text-decoration:none; }
    a:hover    { font-size:9pt; color:blue; }
    td { font-size:9pt; color:black;}
    td.head { font-size:9pt; color:white; background-color:#111188; text-align:center;}
    td.menu { font-size:9pt; background-color:white; color:navy }
    td.button { font-size:9pt; background-color:#EEEEEE; cursor:hand; }
    tr { text-align:center; }
    .2daybutton{ font-size:9pt; border-left:1px solid; border-right:1px solid; border-bottom:1px solid; border-top:1px solid }
   </style>
   <script language='Javascript'>
    function Search_it(){
     if ( search.value != \"\" )
      document.location.href='./list.php?table=$pro_table&field='+field.value+'&search='+search.value;
     else
      document.location.href='./list.php?table=$pro_table';
    }
   </script>
  </head>
  <body>
  <table border=0 width=610>
   <tr>
    <td>
    <table width='100' border='0' cellspacing='1' align='left' valign='bottom'>
     <tr>
      <td class='menu'> $admin_link </td>
     </tr>
    </table>
    <table width='260' border='0' cellpadding='0' cellspacing='3' align='right'>
     <tr>
      <td width='60'>
       <select name='field' class='border'>
        <option value='title'>제 목</option>
        <option value='passage'>내 용 </option>
        <option value='writer'>글쓴이</option>
       </select>
      </td>
      <td width='200'><input type='text' name='search' size='20' maxlength='30' class='2daybutton'>&nbsp;
        <input type='button' name='press' value='검 색' class='2daybutton' onclick='Search_it()'>
      </td>
     </tr>
    </table>
    </td>
   </tr>
   <tr>
    <td>
    <table width=600 border=0 cellpadding=0 cellspacing=1 bgcolor='black'>
    <tr height=20>
     <td width=50 class='head'> 번호 </td>
     <td width=300 class='head'> 제목 </td>
     <td width=100 class='head'> 이름 </td>
     <td width=100 class='head'> 날짜 </td>
     <td width=50 class='head'> 조회수 </td>
    </tr>
    <!-- 리스트 출력 시작 -->
  $LIST
    <!-- 리스트 출력 끝 -->
    <tr height=20>
     <td class='menu' colspan=3>$prev_link2$prev_link $short_cut $next_link$next_link2</td>
     <td class='menu' colspan=2>
      <table bgcolor='black' width='100' cellspacing='1'>
       <tr>
        <td class='button' onclick=\"location.href='./writeform.php?table=$pro_table';\">글쓰기</td>
       </tr>
      </table>
     </td>
    </tr>
    </table>
    </td>
   </tr>
  </table>
  </body>
  </html>";
 
?>

이올린에 북마크하기
2007/04/24 14:50 2007/04/24 14:50
http://jiny.kr/trackback/16
전체 (406)
지니소식 (4)
자료실 (4)
정보|뉴스 (5)
SmartPhone (1)
Languages (206)
Server (153)
Database (27)
Design (4)
Gallery (0)
분류하기귀찬.. (2)
«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
  1. 창의력과 상상력을 넘어서  2009
    Tomcat 6.0 기본 환경 설정
  2. 닥공  2009
    서블릿 tomcat 6.0 실행시 에러
  1. 2010/07 (1)
  2. 2010/05 (1)
  3. 2010/02 (3)
  4. 2010/01 (3)
  5. 2009/05 (2)
Statistics Graph