리스트에서 자동으로 입력여부...

리스트에서 자동으로 입력여부...

QA

리스트에서 자동으로 입력여부...

본문

아래코드는 게시판 리스트 -list.skin.php- 파일입니다.
일정추가버튼을 클릭하면 오늘 날짜로 자동입력되게 하고자 합니다.

<?php if ($write_href) { ?><li><a href="<?php echo $write_href ?>" class="btn_b02"><font color="#ffffff">일정추가</font></a></li><?php } ?> 이부분...일정추가 부분을 클릭하면 글쓰기에서 날짜를 선택하게 되어있습니다.

 // 날짜를 클릭하면 글씨쓰기가 가능한 링크를 넣어서 출력하기
      echo "<a href='$write_href&f_date=$f_date'><font color='$daycolor' title='일정추가'>$daytext</font></a>$moonday <font color='$daycontcolor'>$daycont</font>$blank $annivmoonday"; 이부분은 리스트에서 해당 날짜를 클릭하면 해당 날짜에 바로 적용됩니다.

제가 원하는 것은 일정추가 버튼을 클릭하면 오늘 날짜로 바로 적용이 되었으면합니다.

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

include_once("$board_skin_path/moonday.php"); // 석봉운님의 음력날짜 함수

if (eregi('%', $width)) {
  $col_width = "14%"; //표의 가로 폭이 100보다 크면 픽셀값입력
} else{
  $col_width = round($width/7); //표의 가로 폭이 100보다 작거나 같으면 백분율 값을 입력
}
$col_height= 80 ;//내용 들어갈 사각공간의 세로길이를 가로 폭과 같도록
$today = getdate(); 
$b_mon = $today['mon']; 
$b_day = $today['mday']; 
$b_year = $today['year']; 
if ($year < 1) { // 오늘의 달력 일때
  $month = $b_mon;
  $mday = $b_day;
  $year = $b_year;
}

if(!$year) $year = date("Y");
$file_index = $board_skin_path."/day"; ### 기념일 폴더 위치 지정

### 양력 기념일 파일 지정 : 해당년도 파일이 없으면 기본파일(solar.txt)을 불러온다
if(file_exists($file_index."/".$year.".txt")) {
$dayfile = file($file_index."/".$year.".txt");
} else { 
$dayfile = file($file_index."/solar.txt");
}

$lastday=array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if ($year%4 == 0) $lastday[2] = 29;
$dayoftheweek = date("w", mktime (0,0,0,$month,1,$year));
?>

<link rel="stylesheet" href="<?php echo $board_skin_url ?>/style.css">

<table width="<?=$width?>" border=0 cellpadding="0" cellspacing="0">
  <tr>
       <td width="20%" class="fg_title"> </td>
       <td width="60%" height="30" align="center">
<table border="0" cellspacing="5" cellpadding="0">
<tr>
<td><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"; ?><?if ($month == 1) { $year_pre=$year-1; $month_pre=$month; } else {$year_pre=$year-1; $month_pre=$month;} echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no");?>"><img src="<?=$board_skin_url?>/img/y_prev.gif" border="0" alt="<?=$year_pre?>년"></a></td>
<td><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"; ?><?if ($month == 1) { $year_pre=$year-1; $month_pre=12; } else {$year_pre=$year; $month_pre=$month-1;} echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no");?>"><img src="<?=$board_skin_url?>/img/m_prev.gif" border="0" alt="<?=$month_pre?>월"></a></td>
<td style="padding:0 10px;font-size:18px;font-weight:bold;"><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table; ?>" title="오늘로" onfocus="this.blur()"><? echo ("$year".년." $month".월); ?></a></td>
<td><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"; ?><?if ($month == 12) { $year_pre=$year+1; $month_pre=1; } else {$year_pre=$year; $month_pre=$month+1;} echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no");?>"><img src="<?=$board_skin_url?>/img/m_next.gif" border="0" alt="<?=$month_pre?>월"></a></td>
<td><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"; ?><?if ($month == 12) { $year_pre=$year+1; $month_pre=$month; } else {$year_pre=$year+1; $month_pre=$month;} echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no");?>"><img src="<?=$board_skin_url?>/img/y_next.gif" border="0" alt="<?=$year_pre?>년"></a></td>
</tr>
</table>
</td>
<td width="20%" align="right">
        <?php if ($rss_href || $write_href) { ?>
        <ul class="btn_bo_user">
            <?php if ($rss_href) { ?><li><a href="<?php echo $rss_href ?>" class="btn_b01">RSS</a></li><?php } ?>
            <?php if ($admin_href) { ?><li><a href="<?php echo $admin_href ?>" class="btn_admin"><font color="#ffffff">관리자</font></a></li><?php } ?>
            <?php if ($write_href) { ?><li><a href="<?php echo $write_href ?>" class="btn_b02"><font color="#ffffff">일정추가</font></a></li><?php } ?>
        </ul>
        <?php } ?>
</td>
  </tr>
</table>

<div id="bo_list">
<table width="<?=$width?>" bgcolor="#cfcfcf" border="0" cellspacing="1" cellpadding="5">
<thead>
  <tr bgcolor="#fdfac2" align="center">     
<th style="color:red">SUN</th>
<th>MON</th>
<th>TUE</th>
<th>WED</th>
<th>THU</th>
<th>FRI</th>
<th style="color:blue">SAT</th>
  </tr>
</thead>
<tbody>
<?
$cday = 1;
$sel_mon = sprintf("%02d",$month);
$query = "SELECT * FROM $write_table WHERE mb_id='{$member[mb_id]}' and left(wr_1,6) <= '$year$sel_mon' and left(wr_2,6) >= '$year$sel_mon' ORDER BY wr_id ASC";  // 변경

$result = sql_query($query);
$j=0; // layer id
// 내용을 보여주는 부분
while ($row = mysql_fetch_array($result)) {  // 제목글 뽑아서 링크 문자열 만들기..
  if( substr($row[wr_1],0,6) <  $year.$sel_mon ) {
$start_day =1; 
$start_day= (int)$start_day;
  } else {
$start_day = substr($row[wr_1],6,2);
     $start_day= (int)$start_day;
  }

  if( substr($row[wr_2],0,6) >  $year.$sel_mon ) {
$end_day = $lastday[$month];
$end_day= (int)$end_day;
  } else {
$end_day = substr($row[wr_2],6,2);
$end_day= (int)$end_day;
  }

  // 아이디에 따라 다른 아이콘이미지 출력 하고 싶을때 ///주석을 해제
  $imgown = 'icon';

  for ($i = $start_day ; $i <= $end_day;  $i++) {

    if (strlen($row[wr_3]) > 0) {  // 입력된 아이콘 값이 있을 때
      $imgown = $row[wr_3] ;
}

    $j++; // layer ID

    $list[comment_cnt] = " ".$row[wr_comment]; // row에 대하여 코멘트 카운터 정의
    if($row[wr_comment] == 0) {
      $list[comment_cnt] = null ;
    } else {
 if($list[comment_cnt]!=null) $list[comment_cnt] = "<b><font color=#ff6600>".$list[comment_cnt]."</font></b>"; 
    }

    $row[wr_subject] = cut_str(get_text($row[wr_subject]),$board[bo_subject_len],"…"); // subject length cut

    $list['icon_new'] = '';
if ($row['wr_datetime'] >= date("Y-m-d H:i:s", G5_SERVER_TIME - ($board['bo_new'] * 3600)))
      $list['icon_new'] = " <img src='$board_skin_url/img/icon_new.gif' align='absmiddle' alt='새글'>";

    if ($member[mb_level] < $board[bo_read_level]) {
      $showLayer="" ;
    } else { 
      $showLayer=" onmouseover=\"PopupShow('".$j."')\" onmouseout=\"PopupHide('".$j."')\" ";
    }
    $html_day[$i].= "<br /><img src='$board_skin_url/img/".$imgown.".gif' border=0 align=absmiddle /> <a href='".G5_BBS_URL."/board.php?bo_table=$bo_table&year=$year&month=$month&wr_id=$row[wr_id]&sc_no=$sc_no' id='subject_".$j."' ".$showLayer.">".$row[wr_subject]."</a>".$list[icon_new].$list[comment_cnt];
?>


    <DIV ID="popup_<?=$j?>" class="popup_layer"> 
<?
    $html = 0;
    if (strstr($row[wr_option], "html1"))
      $html = 1;
    else if (strstr($row[wr_option], "html2"))
      $html = 2;

      $viewlist = cut_str(conv_content($row[wr_content], $html),200,"…");
 echo "( 작성자 : ".$row[wr_name]." )<br />";
      echo $viewlist;
?>
    </DIV>
    </DIV>
<?
//오늘 스케줄 구하기
if ($row[wr_id] != $sc_id && date('Ymd', strtotime($row[wr_1])) <= date(Ymd) && date('Ymd', strtotime($row[wr_2])) >= date(Ymd)) {
$today_schedule .= "<p><img src='$board_skin_url/img/".$imgown.".gif' border=0 align=absmiddle />";
$today_schedule .= " <a href='".G5_BBS_URL."/board.php?bo_table=$bo_table&year=$year&month=$month&wr_id=$row[wr_id]&sc_no=$sc_no'><b>".$row[wr_subject]."</b></a>";
$today_schedule .= " (".substr($row['wr_1'],4,2)."/".substr($row['wr_1'],6,2)." ~ ".substr($row['wr_2'],4,2)."/".substr($row['wr_2'],6,2).")<br />";
$today_schedule .= $viewlist."</p>";
}
$sc_id = $row[wr_id];
    }
  }

  // 달력의 틀을 보여주는 부분

  $temp = 7- (($lastday[$month]+$dayoftheweek)%7);

  if ($temp == 7) $temp = 0;
     $lastcount = $lastday[$month]+$dayoftheweek + $temp;

  for ($iz = 1; $iz <= $lastcount; $iz++) { // 42번을 칠하게 된다.
    $bgcolor = "#ffffff";  // 쭉 흰색으로 칠하고
    if ($b_year==$year && $b_mon==$month && $b_day==$cday) $bgcolor = "#DEFADE";      //  "#DFFDDF"; // 오늘날짜 연두색으로 표기
    if (($iz%7) == 1) echo ("<tr>"); // 주당 7개씩 한쎌씩을 쌓는다.
    if ($dayoftheweek < $iz  &&  $iz <= $lastday[$month]+$dayoftheweek) {
// 전체 루프안에서 숫자가 들어가는 셀들만 해당됨
// 즉 11월 달에서 1일부터 30 일까지만 해당
$daytext = "$cday";   // $cday 는 숫자 예> 11월달은 1~ 30일 까지
//$daytext 은 셀에 써질 날짜 숫자 넣을 공간
$daycontcolor = "" ; 
$daycolor = ""; 
if ($iz%7 == 1) $daycolor = "red"; // 일요일
if ($iz%7 == 0) $daycolor = "blue"; // 토요일

// 여기까지 숫자와 들어갈 내용에 대한 변수들의 세팅이 끝나고 
// 이제 여기 부터 직접 셀이 그려지면서 그 안에 내용이 들어 간다.
echo ("<td width=$col_width height=$col_height bgcolor=$bgcolor valign=top>");

$f_date = $year.sprintf("%02d",$month).sprintf("%02d",$cday);

// 기념일 파일 내용 비교위한 변수 선언, 월과 일을 두자리 포맷으로 고정
if (strlen($month) == 1) { 
$monthp = "0".$month ;
} else {
$monthp = $month ; 
}
if (strlen($cday) == 1) {
$cdayp = "0".$cday ;
} else { 
$cdayp = $cday ; 
}
$memday = $year.$monthp.$cdayp;
$daycont = "" ;

// 기념일(양력) 표시
for($i=0 ; $i < sizeof($dayfile) ; $i++) {  // 파일 첫 행부터 끝행까지 루프
$arrDay = explode("|", $dayfile[$i]);
if($memday == $year.$arrDay[0]) {
$daycont = $arrDay[1]; 
$daycontcolor = $arrDay[2];
if(substr($arrDay[2],0,3)=="red") $daycolor = "red"; // 공휴일은 날짜를 빨간색으로 표시
}
}

    // 석봉운님의 음력날짜 변수선언
    $myarray = soltolun($year,$month,$cday);
    if ($myarray[day]==1 || $myarray[day]==11 || $myarray[day]==21) {
      $moonday ="<font color='gray'> (음)$myarray[month].$myarray[day]$myarray[leap]</font>";
    } else {
      $moonday="";
    }

include($file_index."/lunar.txt"); ### 음력 기념일 파일 지정

    if ($annivmoonday&&$daycont) $blank="<br />"; // 음력절기와 양력기념일이 동시에 있으면 한칸 띔
    else $blank="";

    if ($write_href) { 
      // $write_href (글쓰기 권한)이 있으면
      // 날짜를 클릭하면 글씨쓰기가 가능한 링크를 넣어서 출력하기
      echo "<a href='$write_href&f_date=$f_date'><font color='$daycolor' title='일정추가'>$daytext</font></a>$moonday <font color='$daycontcolor'>$daycont</font>$blank $annivmoonday";
    } else { // 글쓰기 권한이 없으면 글쓰기 링크는 넣지 않고 그냥 숫자와 기념일 내용만 출력하기  
      echo "<font color='$daycolor'>$daytext</font>$moonday <font color='$daycontcolor'>$daycont</font>$blank $annivmoonday";
    }
    echo $html_day[$cday];
    echo ("</td>");  // 한칸을 마무리
    $cday++; // 날짜를 카운팅
  } 
  // 유효날짜가 아니면 그냥 회색을 칠한다.
  else { echo ("     <td width=$col_width height=$col_height bgcolor=f9fafe valign=top> </td>"); }
  if (($iz%7) == 0) echo ("  </tr>");
   
} // 반복구문이 끝남
?>
</tbody>
</table>
</div>

이 질문에 댓글 쓰기 :

답변 3

감사요. 안되던데요.

이렇게 해결요. 글쓰기에 write.skin.php 파일에 아래처럼 혹 문제는 없나요

<input type="text" name="wr_1" value='<?php $current_date = date("Ymd"); echo$current_date;?>' readonly id="wr_1" required class="frm_input required" size="8" maxlength="8"> 
<input type="text" name="wr_2" value='<?php $current_date = date("Ymd"); echo$current_date;?>' readonly id="wr_2" required class="frm_input required" size="8" maxlength="8">

네 다른용도로 사용하려고하니 상관없어요
아예 날짜를 클릭해서 입력부분은 없애고 사용할거라서요...
감사요.
근데
<input type="text" name="wr_subject" value="<?php echo $subject ?>오늘 오신 날. 체크합니다." id="wr_subject" required class="frm_input required" size="50" maxlength="255">
글쓰기 부분에서 제목인데요 -오늘 오신 날. 체크합니다.-  이 부분 수정 금지하고자 하는데 어케하는지 예전에 있던데 찾아보려니 안보이네요

일정추가 버튼에 오늘날짜는 넣어서 값을 넘겨주면 되지 않을까요...
if ($write_href) { ?><li><a href="<?php echo $write_href.'&f_date='.date(Ymd) ?>" class="btn_b02"><font color="#ffffff">일정추가</font></a></li>
답변을 작성하시기 전에 로그인 해주세요.
전체 5
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT