작성 시간순이 아니라 강제 순서 배열
본문
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
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;
}
$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));
?>
<style type="text/css">
.zp_schedule { border-collapse:collapse; border-spacing: 0 ; width:100%; font-size:8pt;}
.zp_schedule th,
.zp_schedule td { border:1px solid #DDDDDD; padding:7px 0px; line-height:11px; }
.zp_schedule th { text-align:center; font-weight:bold; background:#F9F9F9; padding:11px; }
</style>
<!-- 게시판 목록 시작 { -->
<div id="bo_list" style="width:<?php echo $width; ?>">
<!-- 게시판 페이지 정보 및 버튼 시작 { -->
<div class="bo_fx">
<div id="bo_list_total" style="padding:0 0 11px 394px;">
<a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"?><?php 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");?>" target="_self" onfocus="this.blur()"> << </a>
<a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"?>" onfocus="this.blur()"><strong><?php echo ("$year".년); ?></strong> <strong><?php echo ("$month".월); ?></strong></a>
<a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"?><?php 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");?>" target="_self" onfocus="this.blur()"> >> </a>
</div>
<?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">관리자</a></li><?php } ?>
<?php if ($write_href) { ?><li><a href="<?php echo $write_href ?>" class="btn_b02">글쓰기</a></li><?php } ?>
</ul>
<?php } ?>
</div>
<!-- } 게시판 페이지 정보 및 버튼 끝 -->
<table class="zp_schedule">
<tr>
<th><span style="color:#FF0000">일요일</span></th>
<th>월요일</th>
<th>화요일</th>
<th>수요일</th>
<th>목요일</th>
<th>금요일</th>
<th><span style="color:#0000FF">토요일</span></th>
</tr>
<?php
$cday = 1;
$sel_mon = sprintf("%02d",$month);
$query = "select * from $write_table where 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 = sql_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++) {
$j++; // layer ID
$list['comment_cnt'] = "(".$row['wr_comment'].")";
if($row['wr_comment'] == 0) {
$list['comment_cnt'] = null ;
} else {
if($row['wr_last'] >= date("Y-m-d H:i:s", G5_SERVER_TIME - (24 * 3600))) {
$list['comment_cnt'] = " (".$row['wr_comment'].")";
if($list['comment_cnt']!=null) $list['comment_cnt'] = "<span class='small'>".$list['comment_cnt']."</span>";
} else {
$list['comment_cnt'] = "<span class='small'>".$list[$i]['comment_cnt']."</span>" ;
}
}
$list['icon_new'] = null;
$row['wr_subject'] = cut_str(get_text($row['wr_subject']),$board['bo_subject_len'],"..."); // subject length cut
$row['wr_7'] = cut_str(get_text($row['wr_7']),"2","*"); // subject length cut
//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_path."/img/icon_new.gif' style='vertical-align:middle;' alt='new'>";
if($row['ca_name']) {
$ca_name ="<span style='font-size:11px;color:#22B14C;'>[".$row['ca_name']."]</span><br />";
}
$ahref = "<a href='".G5_BBS_URL."/board.php?bo_table=".$bo_table."&year=".$year."&month=".$month."&wr_id=".$row['wr_id']."'>";
if($row['wr_8'] == 'babo') {
} else {
$html_day[$i].= "<div style='padding:2px; margin:0 0 2px 0; background:".$row['wr_3'].";'>".$ahref.$mb_id."<span style='color:".$row['wr_4'].";'>".$ca_name."<span style='color:#f79100;'>".$row['wr_9']."</span>".$row['wr_subject'].$row['wr_7'].$list['comment_cnt']."</span></a></div>";
}
}
}
$temp = 7- (($lastday[$month]+$dayoftheweek)%7);
if($temp == 7) $temp = 0;
$lastcount = $lastday[$month]+$dayoftheweek + $temp;
for ($iz = 1; $iz <= $lastcount; $iz++) {
$bgcolor = "#ffffff";
if($b_year==$year && $b_mon==$month && $b_day==$cday) $bgcolor = "#ffffff";
if(($iz%7) == 1) echo ("<tr>");
if($dayoftheweek < $iz && $iz <= $lastday[$month]+$dayoftheweek){
$daytext = "$cday";
$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;
$memday = $monthp.$cdayp;
$daycont = "" ;
if($write_href) {
echo "<a href='".$write_href."&f_date=".$f_date."&t_date=".$f_date."'><span style='color:".$daycolor."; margin:0 0 0 2px;'>".$daytext."</span></a>";
} else {
echo "<span style='color:".$daycolor."; margin:0 0 0 2px;'>".$daytext."</span>";
}
echo $html_day[$cday];
echo ('</td>');
$cday++;
}
else { echo ("<td width='".$col_width."' height='".$col_height."' valign='top'></td>"); }
if(($iz%7) == 0) echo ('</tr>');
}
?>
</table>
</div>
여기서..
시간 순서대로 달력에 표기가 될텐데요.
그게 아니라 wr_8 값에 따라 배열이 되었으면 합니다.
wr_8값을 입력 받고 1/2/3/4/5/6/... 이런 순서식으로...
입력 시 4가 먼저 입력되고... 나중에 1이 입력되면
원래 순서면
4
1
이렇지만..
강제로
1
4
이렇게 갈 수 있게요..
답변 1
$query = "select * from $write_table where left(wr_1,6) <= '".$year.$sel_mon."' and left(wr_2,6) >= '".$year.$sel_mon."' order by wr_id asc";
뭐리문의 order by 를 변경해 보세요
$query = "select * from $write_table where left(wr_1,6) <= '".$year.$sel_mon."' and left(wr_2,6) >= '".$year.$sel_mon."' order by wr_8 asc";