열람 내역 뽑기. 초보좀 도와주세요 ㅠㅠ 채택완료

아미나를 사용중인데요. 아미나에는 포인트를 내고 열람하는 게시판이 있습니다.

각 게시판 뷰 페이지 마다 열람자 목록을 표기하고 싶은데요.

정말 검색 많이 한 결과 추천인 로그를 뽑아오는 애드온을 발견했습니다.

방식도 비슷하고, 표현하고자 하는 부분도 비슷합니다.

다만, 이건 추천인이고, 저는 열람 내역을 뽑아 오고 싶거든요.

또 엄청나게 검색해보니 열람 내역을 뽑기 위해서는 DB포인트 로그 테이블에서 flag가 열람인 것을 뽑으면 된다는 말을 들었습니다. 

1888497194_1659409644.3281.jpg

db 포인트 테이블을 보니 이런식이었습니다.

하여

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

global $view, $wr_id, $bo_table;

//애드온 사용시에만 출력
if($wset['use']) {
    if($view['wr_good'] > 0) {
    add_stylesheet('<link rel="stylesheet" href="'.$widget_url.'/widget.css" media="screen">', 0);

    $wset['bo_list'] = ($wset['bo_list']) ? $wset['bo_list'] : $bo_table;
    // 추출
    $gr_list = (isset($wset['gr_list']) && $wset['gr_list']) ? apms_escape_string($wset['gr_list']) : '';
    $bo_list = (isset($wset['bo_list']) && $wset['bo_list']) ? apms_escape_string($wset['bo_list']) : '';
    $chk_bo_table = ($gr_list) ? apms_group_board($gr_list) : $bo_list;
    $sql_board = '';
    if($chk_bo_table) {
        $sql_board = (isset($wset['except']) && $wset['except']) ? "and find_in_set(a.bo_table, '{$chk_bo_table}')=0" : "and find_in_set(a.bo_table, '{$chk_bo_table}')";
    }

    $sql = " select a.mb_id, b.as_photo, b.mb_nick, b.mb_email, b.mb_homepage  from g5_board_good  a left join g5_member b on (a.mb_id = b.mb_id)
                where a.bo_table ='".$bo_table."' and a.wr_id =$wr_id and a.bg_flag ='good' $sql_board order by a.bg_datetime desc" ;
    $result = sql_query($sql, false);
    
    ?>
    <?php if (sql_num_rows($result) != 0) { ?>
    <div id="goods_member_list_wrap">
        <div id="goods_member_list" class="add_goods_list">
            <div class="subject_wrap">
                <?php echo $wset['goods_title']?><span class="total_count"> <?php echo number_format($view['wr_good']) ?></span><?php echo $wset['goods_btitle']?>
            </div>
            <div class="list_wrap">
            <ul>
            <?
                for ($i=0; $row=sql_fetch_array($result); $i++) {
            ?>
                <li>
                    <?php 
                        $cmt_photo_url = apms_photo_url($row['mb_id']);
                        $cmt_photo = ($cmt_photo_url) ? '<img src="'.$cmt_photo_url.'" alt="" class="media-object">' : '<div class="media-object"><i class="fa fa-user"></i></div>';
                        echo '<div class="photo">'.$cmt_photo.'</div>'.PHP_EOL;

                        ?>
                        <?php echo apms_sideview($row['mb_id'], get_text($row['mb_nick']), $row['mb_email'], $row['mb_homepage'], $lvl); ?>
                        
                </li>            
            <?php } ?>        
            </ul>            
            </div>
        </div>
    </div>
    <?php } ?>
    <?php } ?>
<?php } ?>

<?php if($setup_href) { ?>
    <p class="btn-wset text-center">
        <a href="<?php echo $setup_href;?>" class="win_memo">
            <span class="text-muted font-12"><i class="fa fa-cube"></i> 추천인 표시 애드온 설정</span>
        </a>
    </p>
<?php } ?>

해당 소스에서 

g5_board_good -> $g5_point_table

a.bg_flag ='열람'

으로 수정해 보았으나 출력되지가 않네요.

어떻게 수정하면 될까요.. 초보좀 도와주시면 정말 감사드리겠습니다. 

답변 2개

채택된 답변
+20 포인트
Copy
$sql = "
  select a.mb_id, b.as_photo, b.mb_nick, b.mb_email, b.mb_homepage  
    from g5_point a left join g5_member b on (a.mb_id = b.mb_id)
   where a.po_rel_table = '{$bo_table}'
     and a.po_rel_id = '{$wr_id}'
     and a.po_rel_action = '열람'
   order by a.po_datetime desc
";
로그인 후 평가할 수 있습니다

답변에 대한 댓글 5개

죄송한데, 출력을 하려면 어떻게 하면 될까요

<?php echo number_format($view['a.po_rel_action']) ?>, <?php echo number_format($view['출력']) ?> 등을 넣어도 출력이 되질 않습니다 ㅠ
질문을 이해하지 못했습니다.
위 내용은 db에서 정보를 읽어오는 걸로 보이는데... 저걸 표현하려면 어떻게 해야하는지 모르겠습니다..
질문을 이해하지 못했습니다.

※ https://hongpage.kr/35
[code]
$sql = "
select a.mb_id, b.as_photo, b.mb_nick, b.mb_email, b.mb_homepage
from g5_point a left join g5_member b on (a.mb_id = b.mb_id)
where a.po_rel_table = '{$bo_table}'
and a.po_rel_id = '{$wr_id}'
and a.po_rel_action = '열람'
order by a.po_datetime desc
";

$result = sql_query($sql);

for ($i = 0; $row = sql_fetch_array($result); $i++) {
echo $row['mb_id'];
echo $row['mb_nick'];
}
[/code]

[code]
$sql = "
select mb_id, po_point
from g5_point
order by 1 desc
limit 1
";

$row = sql_fetch($sql);
echo $row['mb_id'];
echo $row['po_point'];
[/code]
감사합니다! 덕분에 해결한 것 같습니다!

댓글을 작성하려면 로그인이 필요합니다.

a.po_rel_action='열람'

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

조금만 자세히 설명해 주시면 안될까요 ㅠㅠㅠㅠㅠㅠㅠㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고