진행중인 포인트경매를 게시물에 출력하기 > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

진행중인 포인트경매를 게시물에 출력하기 정보

진행중인 포인트경매를 게시물에 출력하기

본문

노란색 부분의 테이블명을 바꾸어서 사용하세요.

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

$dotted_color = array("red", "green", "blue");
$dcolor = $dotted_color[rand(0, count($dotted_color)-1)];
?>
<br>
<table width=650 align=center cellpadding=5 style='border:2px dotted <?=$dcolor?>;'>
<tr>
<td align='center' style="padding:10px 0 10px 10px;">
    <h3 style='float:left; margin-bottom:10px;'><a href="<?=$g4[bbs_path]?>/board.php?bo_table=auction">♡ 포인트 경매</a></h3>

<?
$sql = " select * from g4_write_auction where '$g4[time_ymdhis]' < wr_2 order by wr_2 asc ";
$result = sql_query($sql, true);
for ($i=0; $row=sql_fetch_array($result); $i++) {
    $style = "";
    if (strtotime($row[wr_2]) < $g4[server_time] + (3600 * 6)) {
        $style = "color:crimson;";
    }

    $color = $acolor[rand(0, count($acolor)-1)];
    $num = $i + 1;

    $subject = explode("|", $row[wr_subject]);
    echo "<div style='font-size:12px; padding:2 0 2 0; clear:both; cursor:pointer; text-decoration:normal; text-align:left; $style' onclick=\"document.location='/bbs/board.php?bo_table=auction&wr_id=$row[wr_id]'\">\n";
        //echo "<div style='float:left; color:blue; font-family:Gulim;'>경매남은시간 : </div>";
        echo "<div style='border-bottom:1px solid #ccc; padding-bottom:5px; margin-bottom:5px;'>";
        echo "<span style='font-weight:normal; color:#556677; font-family:Gulim;'>$num. $subject[1]</span> <span style='color:#ff6600; font:10px tahoma;'>(".number_format($row[wr_7]).")</span>";
        echo "<span id='time{$i}' style='color:green; font-family:Dotum; font-size:12px; margin-left:10px;'></span>";
        echo "</div>";
    echo "</div>\n";

    $time = "t{$i}";
    $end_time = strtotime($row[wr_2])-$g4[server_time];

    echo "<script>";
    echo "var $time = new Timer(); ";
    echo "$time.id = 'time$i'; ";
    echo "$time.end_time = $end_time; ";
    echo "$time.run(); ";
    echo "$time.tid = setInterval(\"$time.run()\", 1000); ";
    echo "</script>\n";
}
if ($i==0) echo "<div align='center'>현재 진행중인 포인트 경매가 없습니다.</div>";
?>

</td>
</tr>
</table>
<br><br>

<script type="text/javascript">
function Timer() {
    this.end_time = null;
    this.id = null;
    this.tid = null;
    this.run = function() {
        //alert(this.xxx);
        var timer = document.getElementById(this.id);

        dd = Math.floor(this.end_time/(60*60*24));
        hh = Math.floor((this.end_time%(60*60*24))/(60*60));
        mm = Math.floor(((this.end_time%(60*60*24))%(60*60))/60);
        ii = Math.floor((((this.end_time%(60*60*24))%(60*60))%60));

        var str = "";

        if (dd > 0) str += dd + "일 ";
        if (hh > 0) str += hh + "시간 ";
        if (mm > 0) str += mm + "분 ";
        str += ii + "초 ";

        timer.innerHTML = str;

        this.end_time--;

        if (this.end_time < 0) clearInterval(this.tid);
    }
}
</script>

추천
6
  • 복사

댓글 10개

아래 자바스크립트 소스를 호출하기전에 상단위치로 이동하면 에러 안납니다.

<script type="text/javascript">
function Timer() {
    this.end_time = null;
    this.id = null;
    this.tid = null;
    this.run = function() {
        //alert(this.xxx);
        var timer = document.getElementById(this.id);

        dd = Math.floor(this.end_time/(60*60*24));
        hh = Math.floor((this.end_time%(60*60*24))/(60*60));
        mm = Math.floor(((this.end_time%(60*60*24))%(60*60))/60);
        ii = Math.floor((((this.end_time%(60*60*24))%(60*60))%60));

        var str = "";

        if (dd > 0) str += dd + "일 ";
        if (hh > 0) str += hh + "시간 ";
        if (mm > 0) str += mm + "분 ";
        str += ii + "초 ";

        timer.innerHTML = str;

        this.end_time--;

        if (this.end_time < 0) clearInterval(this.tid);
    }
}
</script>
© SIRSOFT
현재 페이지 제일 처음으로