도와주세요 ㅠㅠ 댓글 갯수 표시에서...ㅠㅠ
관련링크
본문
안녕하세요 그누보드 초보입니다 ㅜㅜ
일전에 여기서 도움을 받아 기존에 list_skin.php에서 최근 7일간 등록된 댓글 갯수를 목록에 표시하였는데요.
for ($i=0; $i<count($list); $i++) {
$sql = "select count(*) as cnt from {$write_table} where wr_datetime>=DATE_ADD(now(), interval -1 WEEK) and wr_parent='{$list[$i]['wr_id']}' and wr_is_comment=1";
$rows = sql_fetch($sql);
$com_count = (int)$rows['cnt'];
출력은 $com_count로
이렇게 해서 완벽하게 글목록에서 출력이 되는데
다음지도 api에서 다수의 마커 인포창에 최근 7일간 등록된 댓글 갯수를 표시하려니 너무너무 힘이 듭니다. 벌써 이틀째 머리 짜내고 있어요 ㅠㅠ
다음지도 api상에서
<?
$sql = " select * from {$write_table} order by wr_id asc ";
$result = sql_query($sql);
$cnt = 0;
while ($row = sql_fetch_array($result))
{
if($row[wr_29] && $row[wr_30]) {
for ($i=0; $i<count($list); $i++) {
$sql = "select count(*) as cnt from {$write_table} where wr_datetime>=DATE_ADD(now(), interval -1 WEEK) and wr_parent='{$list[$i]['wr_id']}' and wr_is_comment=1";
$rows = sql_fetch($sql);
$com_count = (int)$rows['cnt'];
?>
// 마커를 생성합니다
var marker = new daum.maps.Marker({
map: map, // 마커를 표시할 지도
position: new daum.maps.LatLng(<?=$row[wr_29]?>, <?=$row[wr_30]?>) // 마커의 위치
});
var iwContent = '<div style="width:150px;text-align:center;padding:10px 0;"><?=$row[wr_subject]?></div><br> <?=$row[wr_10]?><br> <?=$row[wr_11]?><br> <?=$row[wr_12]?><br> <?=$row[wr_13]?><br> <?=$row[wr_14]?><br><br> <a href="./board.php?bo_table=<?=$GLOBALS['bo_table']?>&wr_id=<?=$row[wr_id]?>" style="color:blue">방보기</a><br><br><br> 최근일주일 등록공실 <?php echo $com_count?>개<br><br>',
removable = true; // removeable 속성을 ture 로 설정하면 인포윈도우를 닫을 수 있는 x버튼이 표시됩니다
var infowindow = new daum.maps.InfoWindow({
content: iwContent,
removable : removable
});
// 마커에 mouseover 이벤트와 mouseout 이벤트를 등록합니다
// 이벤트 리스너로는 클로저를 만들어 등록합니다
// for문에서 클로저를 만들어 주지 않으면 마지막 마커에만 이벤트가 등록됩니다
//daum.maps.event.addListener(marker, 'click', br_redirect(positions[i].wr_id));
// 마커에 click 이벤트를 등록합니다
daum.maps.event.addListener(marker, 'click', makeOverListener(map, marker, infowindow));
<?
$cnt++;
}
}
}
?>
여기서 추가하려니 for문을 넣고 하는것도 안되고 제가 초보다 보니 이것저것 시도해봐도 되질 않습니다 ㅠㅠ
어떻게 해야 뜰까요 ㅠㅠ
도와주세요 ㅠㅠ
!-->!-->답변 6
지도 출력이 리스트인지? 본문인지 모르지만요.
<?php
$sql="select * from {$write_table} order by wr_id asc";
$result=sql_query($sql);
$cnt=0;
for($i=0; $row=sql_fetch_array($result); $i++) {
if($row['wr_29'] && $row['wr_30']) {
$sql="select count(*) as cnt from {$write_table} where wr_datetime>=DATE_ADD(now(), interval -1 WEEK) and wr_parent='{$row['wr_id']}' and wr_is_comment=1";
$rows=sql_fetch($sql);
$com_count=(int)$rows['cnt'];
?>
// 마커를 생성합니다
var marker = new daum.maps.Marker({
map: map, // 마커를 표시할 지도
position: new daum.maps.LatLng(<?php echo $row['wr_29']?>, <?php echo $row['wr_30']?>) // 마커의 위치
});
var iwContent='<div style="width:150px;text-align:center;padding:10px 0;"><?php echo $row['wr_subject']?></div><br> <?php echo $row['wr_10']?><br><?php echo $row['wr_11']?><br><?php echo $row['wr_12']?><br> <?php echo $row['wr_13']?><br> <?php echo $row[wr_14]?><br><br> <a href="./board.php?bo_table=<?php echo $GLOBALS['bo_table']?>&wr_id=<?php echo $row['wr_id']?>" style="color:blue">방보기</a><br><br><br> 최근일주일 등록공실 <?php echo $com_count?>개<br><br>',
removable = true; // removeable 속성을 ture 로 설정하면 인포윈도우를 닫을 수 있는 x버튼이 표시됩니다
var infowindow = new daum.maps.InfoWindow({
content: iwContent,
removable : removable
});
// 마커에 mouseover 이벤트와 mouseout 이벤트를 등록합니다
// 이벤트 리스너로는 클로저를 만들어 등록합니다
// for문에서 클로저를 만들어 주지 않으면 마지막 마커에만 이벤트가 등록됩니다
//daum.maps.event.addListener(marker, 'click', br_redirect(positions[i].wr_id));
// 마커에 click 이벤트를 등록합니다
daum.maps.event.addListener(marker, 'click', makeOverListener(map, marker, infowindow));
<?php
$cnt++;
}
?>
반복문을 중복으로 불러 오신것 같은데요..
처음 답변 무시하시구요..
간결하게 ....
질문으로 올린 소스를 살펴서
<?
$sql = " select * from {$write_table} order by wr_id asc ";
$result = sql_query($sql);
$cnt = 0;
while ($row = sql_fetch_array($result))
{
if($row[wr_29] && $row[wr_30]) {
for ($i=0; $i<count($list); $i++) {
$sql = "select count(*) as cnt from {$write_table} where wr_datetime>=DATE_ADD(now(), interval -1 WEEK) and wr_parent='{$list[$i]['wr_id']}' and wr_is_comment=1";
$rows = sql_fetch($sql);
$com_count = (int)$rows['cnt'];
?>
위에 소스를 아래 소스로 변경해 보세요.
<?php
$cnt=0;
for($i=0; $i<count($list); $i++) {
if($list[$i]['wr_29'] && $list[$i]['wr_30']) {
$sql="select count(*) as cnt from {$write_table} where wr_datetime>=DATE_ADD(now(), interval -1 WEEK) and wr_parent='{$list[$i]['wr_id']}' and wr_is_comment=1";
$rows=sql_fetch($sql);
$com_count=(int)$rows['cnt'];
?>
다음)
이글 바로 위에 올린 사용자분의 소스중
$row - > $list[$i] 이런식으로 모두 바꿔줍니다
예 : $row['wr_10'] - > $list[$i]['wr_10'] 이런식으로
다음)
for문을 닫아주는 소스를
<?php
$cnt++;
}
}
?>
윗 소스처럼 되도록...
답변글 잘 보시고.
절충해서 참고해 보세요.
@송상준
무슨 말씀인지 이해가 안됩니다.
페이지가 어디로 넘어가는지....
소스가 수정 되었으면 그에 맞게 교정/수정이 필요할 수도 이겠죠.
8~12줄은 제가 막 추가한건데 어디에 넣어야 할지를 모르겠어요 ㅠㅠ
댓글 개수랑 조회수도 표시하고픈데 뜨질 않아요 ㅠㅠ