답변 2개
채택된 답변
+20 포인트
9년 전
"만두야닷컴"님의 말씀처럼 wr_hit 필드에 저장된 정보가 출력됩니다.
그런데 보여주신 코드대로하면 $write_table 과 $g5['board_new_table'] 에 저장되는 값이 서로 다를 수 있습니다. 랜덤이니까요...
아래와 같이 해보세요.
</p>
$ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;
if (!get_session($ss_name))
{
$add_hit = rand(1,10);
sql_query(" update {$write_table} set wr_hit = wr_hit + ".$add_hit." where wr_id = '{$wr_id}' ");
sql_query(" update {$g5['board_new_table']} set as_hit = as_hit + ".$add_hit." where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 3개
f
firsttiemuser
9년 전
�
선우善友
9년 전
위와 같이 하면 $write_table과 $g5['board_new_table']의 db에 $add_hit 의 내용이 추가되어 저장됩니다.^^
아마도 "firsttiemuser"님께서 $g5['board_new_table'] 테이블에도 as_hit 필드를 추가하여 조회수가 저장되도록 하신 것 같은데,
두 테이블에 서로 다른 조회수가 저장된다면 해당 게시글을 볼 때와 최신글(bbs/new.php)을 볼 때에 조회수가 서로 다르게 나오게 되니 문제가 될수 있지 않을까요?
아마도 "firsttiemuser"님께서 $g5['board_new_table'] 테이블에도 as_hit 필드를 추가하여 조회수가 저장되도록 하신 것 같은데,
두 테이블에 서로 다른 조회수가 저장된다면 해당 게시글을 볼 때와 최신글(bbs/new.php)을 볼 때에 조회수가 서로 다르게 나오게 되니 문제가 될수 있지 않을까요?
f
firsttiemuser
9년 전
감사합니다!
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 1개
f
firsttiemuser
9년 전
bbs/board.php 135번째줄 기존의 코드를
[code]
// 한번 읽은글은 브라우저를 닫기전까지는 카운트를 증가시키지 않음
$ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;
if (!get_session($ss_name))
{
sql_query(" update {$write_table} set wr_hit = wr_hit + 1 where wr_id = '{$wr_id}' ");
sql_query(" update {$g5['board_new_table']} set as_hit = as_hit + 1 where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
[/code]
아래와 같이 변경했는데
[code]
$ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;
if (!get_session($ss_name))
{
sql_query(" update {$write_table} set wr_hit = wr_hit + ".rand(1,10)." where wr_id = '{$wr_id}' ");
sql_query(" update {$g5['board_new_table']} set as_hit = as_hit + ".rand(1,10)." where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
[/code]
그러면 1회 클릭으로 랜덤 숫자 중 10이 선택됐을때 받아들이기를 10으로 받아들인단 말씀이죠?
[code]
// 한번 읽은글은 브라우저를 닫기전까지는 카운트를 증가시키지 않음
$ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;
if (!get_session($ss_name))
{
sql_query(" update {$write_table} set wr_hit = wr_hit + 1 where wr_id = '{$wr_id}' ");
sql_query(" update {$g5['board_new_table']} set as_hit = as_hit + 1 where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
[/code]
아래와 같이 변경했는데
[code]
$ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;
if (!get_session($ss_name))
{
sql_query(" update {$write_table} set wr_hit = wr_hit + ".rand(1,10)." where wr_id = '{$wr_id}' ");
sql_query(" update {$g5['board_new_table']} set as_hit = as_hit + ".rand(1,10)." where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
[/code]
그러면 1회 클릭으로 랜덤 숫자 중 10이 선택됐을때 받아들이기를 10으로 받아들인단 말씀이죠?
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
혹시 $write_table과 $g5['board_new_table']의 값이 다르면 어떻게 되는건가요?
사이트에서 보이는 값만 올라가고 db에서는 올라가지 않는건가요?