실시간검색어 관련 도와주시면 감사합니다.

실시간검색어 관련 도와주시면 감사합니다.

QA

실시간검색어 관련 도와주시면 감사합니다.

본문


<!-- 실시간검색어-->
<?
$fr_date = date("Y-m-d");
$to_date = date("Y-m-d");
$sql_common = " from {$g5['popular_table']} a ";
$sql_search = " where trim(pp_word) <> '' and pp_date between '{$fr_date}' and '{$to_date}' ";
$sql_group = " group by pp_word ";
$sql = " select pp_word {$sql_common} {$sql_search} {$sql_group} ";
$result = sql_query($sql);
$total_count = sql_num_rows($result);
if($total_count<10){
    $fr_date = date("Y-m-d", strtotime("-3 day"));
    $to_date = date("Y-m-d");
    $sql_search = " where trim(pp_word) <> '' and pp_date between '{$fr_date}' and '{$to_date}' ";
}
$sql_order = " order by cnt desc ";
$sql = "select pp_word, count(*) as cnt {$sql_common} {$sql_search} {$sql_group} {$sql_order} limit 0, 10";
?>
<div class="search_list"><h3 class="tit">실시간검색어</h3>
        <div class="serch_now_list">
        <?php
        $result1 = sql_query($sql);
        for ($a=1; $row=sql_fetch_array($result1); $a++) {
            $word = get_text($row['pp_word']);
        ?>
        <a href="<?php echo G5_BBS_URL ?>/search.php?sfl=wr_subject&wr_content&sop=and&stx=<?php echo $word;?>"><em><?php echo $a;?></em> <?php echo $word;?></a>
        <?php } ?>
        </div>
        <span class="btn_view">∨</span>
</div>
<div class="serch_now_list_view">
        <ul>
        <?php 
        $result2 = sql_query($sql);
        for ($b=1; $row=sql_fetch_array($result2); $b++) {
            $word = get_text($row['pp_word']);
        ?>
        <li><a href="<?php echo G5_BBS_URL ?>/search.php?sfl=wr_subject&wr_content&sop=and&stx=<?php echo $word;?>"><em><?php echo $b;?></em> <?php echo $word;?></a></li>
        <?php } ?>
        </ul>
</div>
<div style="width:100%; height:10px;background-color: #e9ecf3;">
</div>
<script>
$(document).ready(function () {
    $('.btn_view').click(function(){
        var search_view = $(".serch_now_list_view");
        if( search_view.is(":visible") ){
            search_view.slideUp();
            $(this).html("∨");
        }else{
            search_view.slideDown();
            $(this).html("∧");
        }
    });
    function search_list(){
        $(".serch_now_list a:first").slideUp( function(){
            $(this).show();
            $(this).appendTo($(".serch_now_list")).slideDown();
        });
    }
    setInterval(function(){search_list()}, 3000);
});
</script>

 

 

제가 정해진 특정 단어 내에서 검색 시 실시간검색어에 나타나게 하고 싶습니다.

예를 들어 과일을 주제로 한다면 사과나 포도 등 과일 이름을 입력 시에만 실검 순위에 나오게요..ㅠ

어떻게 해야하는지 알려주시면 감사합니답..!....

이 질문에 댓글 쓰기 :

답변 1


$sql_search = " where trim(pp_word) <> '' and pp_date between '{$fr_date}' and '{$to_date}' ";

 

$sql_search = " where trim(pp_word) <> '' and pp_word in ('사과','딸기','바나나') and pp_date between '{$fr_date}' and '{$to_date}' ";

지나가다 기초적으로 생각해보면 .......이런식일꺼 같은데..

속도가 마이 느릴꺼같다능.......ㅡ_ㅡ;

안된다고하셔서 소스가져다가 직접 해보니 잘되는데요;;
$sql_search 가 두군데입니다.. if($total_count<10) { } 안에도 있어요
윗줄에 있는 $sql_search 형태로 된것들을
-> 아래줄에 적어놓은 $sql_search형태로 변경하시면 되요

답변을 작성하시기 전에 로그인 해주세요.
전체 57
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT