게시글 추천 여부 문의 채택완료
안녕하세요.
게시글 리스트에서 추천에 대한 여부를 체크할려고 하는데, 잘 안되어 질문드립니다.
아래의 내 댓글이 있는지 확인하는 쿼리를 이용했는데, 접근방법이 다른것 같습니다.
[내 댓글이 있는지 여부]
</strong></p>
<p>$comment_check = sql_fetch(" select count(*) as cnt from {$write_table} where wr_comment = '{$list[$i][wr_id]}' and mb_id = '{$member[mb_id]}'");</p>
<p><?php if ($comment_check) { ?></p>
<p>...</p>
<p><?php } ?></p>
<p><strong>
[내 추천이 있는지 여부]
</strong></p>
<p>$good_check = sql_fetch(" select count(*) as cnt from {$write_table} where wr_good = '{$list[$i][wr_id]}' and mb_id = '{$member[mb_id]}'");</p>
<p>if ($good_check) {</p>
<p>...</p>
<p><?php } ?></p>
<p><strong>
내 추천이 있는지에 따라서 조건을 걸려고 했으나, 쿼리가 잘못된것 같습니다.
도움주시면 감사하겠습니다.
답변 2개
</p>
<p>$sql = "select count(*) as cnt from <strong>{$g5['board_good_table']}</strong> where bo_table = '{$bo_table}' and wr_id = '{$list[$i][wr_id]}' and mb_id = '{$member[mb_id]}'";</p>
<p>// echo $sql;</p>
<p>$good_check = sql_fetch($sql);</p>
<p> </p>
<p>if($good_check['cnt']){</p>
<p>// 추천이 있다면</p>
<p>}else{</p>
<p>//추천이 없다면</p>
<p>}</p>
<p>
이렇게 해보세요
만일 안된다면 쿼리문 출력 주석문 제거해서 쿼리를 출력해서 원인을 파악하는 방법도 있습니다.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
추천이 저장되는 테이블은 따로있습니다. (테이블명:g5_board_good)
$good_check = sql_fetch(" select count(*) as cnt from {$g5['board_good_table']} where bo_table = '{$bo_table}' and wr_id = '{$list[$i][wr_id]}' and mb_id = '{$member[mb_id]}'");
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$sql = "select count(*) as cnt from {$g5['board_good_table']} where bo_table = '{$bo_table}' and wr_id = '{$list[$i][wr_id]}' and mb_id = '{$member[mb_id]}'";
$row = sql_fetch($sql);
$good_check = $row['cnt'];
[/code]
으로 해결했습니다. 감사합니다.