
현재 마감게시판의 상태이며 여기서 최신글을 불러 오는데 오늘일을 기준으로 마감일이 가장 가까운 글부터 나타내게 하고 싶습니다

이런식으로요 그런데 기존에 있던 스킨 들은 전부 wr_1과 wr_2를 비교하며 순서를 정했던데 저는 보시다 시피 wr_2밖에 없는 상태라 이상태에서 마감일이 제일 가까운순서로 불러오게 하려면 어떻게 해야 될까요?
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
add_stylesheet('<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">', 0);
?>
<ul>
<?
for ($i=0; $i<count($list); $i++)
{
// $prn_temp = substr($list[$i]['wr_datetime'], 5, 5);
// $prn_date = str_replace("-", ".", $prn_temp);
$day_start = date("20y-m-d", strtotime($list[$i]['wr_1']));
$day_now = date("20y-m-d", time());
$day_end = date("20y-m-d", strtotime($list[$i]['wr_2']));
$timediffer=strtotime($day_end) - strtotime($day_now); // 마감일과 오늘의 날짜 차이를 구함
$day = floor(($timediffer)/(60*60*24));
if($list[$i]['wr_2'] > $list[$i]['wr_1']) $subject_len = $subject_len - $options;
$list[$i]['subject'] = cut_str($list[$i]['subject'], $subject_len,"");
?>
<li class="dot">
<p class="title"><? if($list[$i]['ca_name']){?><span class="cate">[<?=$list[$i]['ca_name']?>]</span><?}?><? if($$day_end) {?><span class="cat<?=$day_end;?></span> <?}
else {?><span class="cate"><?=$day_end;?></span> <?}?><a href="<?php echo $list[$i]['href'];?>"><?=$list[$i]['subject']?></a>
D - <?php echo $day ?>
</p>
</li>
<? }
if (count($list) == 0)
{?>
<li><p class="title">등록된 일정이 없습니다.</p></li>
<?}?>
</ul>
최신글 스킨에서 제가 조금 수정한 latest.skin.php.코드입니여기서 wr_1과 $day_now만을 가지고 가까운 순서데로 출력이 나오게 하는게 모르겠네요 ㅠㅠ
답변 1개 / 댓글 3개
wr_1, wr_2, $day_now
wr_2밖에 없다고 하셨다가 제일 밑에는 또 wr_1도 나오고...
기준이 되는 칼럼이 정확히 어떤 건지 알 수 없어서 날짜칼럼이라고 썼습니다.
SELECT * FROM table WHERE 날짜칼럼 > NOW() ORDER BY 날짜칼럼
이런 식으로 하면 오늘 날짜랑 가까운 것들로 정렬이 될 듯하네요.
참고로 질문 내용 중에 20y-m-d라는 게 있는데 2019년 이런 걸 하려고 하신 거면 Y-m-d 쓰시면 됩니다.
답변에 대한 댓글 3개
원래 latest는 다른 데서 쓰니까요.
그리고 아래 쿼리를
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 and wr_2 > NOW() order by wr_2 limit 0, {$rows} ";
이렇게 바꾸면 되지 않을까 싶네요.
답변을 작성하려면 로그인이 필요합니다.