새글아이콘 쿼리문좀 봐주세요
본문
매번 친절한 답변에 감사합니다
메인페이지 좌측에 메뉴를 만들었습니다
원신
몬스터헌터
에픽세븐
라그나로크
바이오하자드
LOL
game 이라는 게시판에 새글이 올라가면 좌측메뉴에 새글아이콘을 넣을려고하는데 잘 안됩니다
wr_1 여분필드에 메뉴랑 같은 게임이름이 저장됩니다
wr_1 = LOL 이 있으면 해당 wr_datetime에서 가장 최신순 1개를 가져와라
이건데 글을 작성하면 무조건 마지막 1개만 가져옵니다 그래서 limit 갯수를 늘이면
메뉴가 해당 갯수만큼 늘어납니다 ㅠㅠ
카운트값으로 도 해보고 이거 저거 해보았지만 도저히 모르겠습니다 조금만 알려주시면 감사하겠습니다
<?php
$sql = " select wr_1 from g5_write_game where wr_is_comment = '0' and wr_1 = wr_1 order by wr_datetime desc limit 0, 1 ";
$result = sql_query($sql);
?>
<div class="game">
<ul>
<?php
for ($i=0; $row=sql_fetch_array($result); $i++)
{
?>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">원신</a>
<?php if($row['wr_1'] == "원신") { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">몬스터헌터</a>
<?php if($row['wr_1'] == "몬스터헌터") { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">에픽세븐</a>
<?php if($row['wr_1'] == "에픽세븐") { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">라그나로크</a>
<?php if($row['wr_1'] == "라그나로크") { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">바이오하자드</a>
<?php if($row['wr_1'] == "바이오하자드") { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">LOL</a>
<?php if($row['wr_1'] == "LOL") { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
</ul>
</div>
답변 3
$sql = "
select wr_1
from g5_write_game
where wr_is_comment = '0'
and wr_ 1 in ('원신', '몬스터헌터', '에픽세븐', '라그나로크', '바이오하자드', 'LOL')
order by wr_datetime desc
limit 1
";
쿼리문에서
wr_1 = wr_1
여기가 잘못된 것 같네요
wr_1 = 'LOL'
이렇게 되야 검색하겠죠
<?php
$sql = "
select wr_1
from g5_write_game
where wr_is_comment = '0'
and wr_ 1 in ('원신', '몬스터헌터', '에픽세븐', '라그나로크', '바이오하자드', 'LOL')
and wr_datetime > now() - interval 12 hour
order by wr_datetime desc
limit 100
";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) {
if ($row['wr_1'] == '원신')
$new_1 = true;
else if ($row['wr_1'] == '몬스터헌터')
$new_2 = true;
else if ($row['wr_1'] == '에픽세븐')
$new_3 = true;
else if ($row['wr_1'] == '라그나로크')
$new_4 = true;
else if ($row['wr_1'] == '바이오하자드')
$new_5 = true;
else if ($row['wr_1'] == 'LOL')
$new_6 = true;
}
?>
<div class="game">
<ul>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">원신</a>
<?php if($new_1) { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">몬스터헌터</a>
<?php if($new_2) { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">에픽세븐</a>
<?php if($new_3) { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">라그나로크</a>
<?php if($new_4) { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">바이오하자드</a>
<?php if($new_5) { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
<li class="half">
<a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=game">LOL</a>
<?php if($new_6) { ?>
<img src="/skin/board/game/img/icon_new.gif">
<?php } ?>
</a>
</li>
</ul>
</div>