자동댓글 수량 랜덤 설정 부탁드려봅니다.

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
자동댓글 수량 랜덤 설정 부탁드려봅니다.

QA

자동댓글 수량 랜덤 설정 부탁드려봅니다.

본문

안녕하세요.

게시글 쓰면 자동으로 랜덤 댓글이 달리게 설정했습니다.

여기서 랜덤으로 닉네임,댓글내용 을 설정해서 잘되는데

수량을 10개 미만에서 랜덤으로 들어가게 하고싶은데

그누보드 검색해서 비슷한내용들을 찾아봤지만 없어서 어쩔수없이 

질문 올립니다.

바쁘시더라도 

답변 부탁드립니다..

이왕이면 자동댓글 수량 10개민으로 랜덤으로 되게 코드 수정해서 부탁드려볼게요 ^^:;

죄송합니다 부탁드려요 ,,제 능력으로는 너무 어렵습니다.

 

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

$reply = array("가나초코렛","임금니미","마켓팅신화","가을비","내밥통");
$randint = mt_rand(0, count($reply)-1);


$array = array('많이 더운날씨네요 건강 챙기세요', '안녕하세요 좋은날씨 입니다.', '방가워요', '좋은 하루 되세요', '오늘 하루도 마무리 잘하세요'); 
$randNum = rand(0,count($array)-1); 


if($w == ''){
    $wr_write = get_write($write_table, $wr_id);//원글정보
    $wr_write_content = $array[$randNum]; //댓글내용
    $wr_write_cname = $reply[$randint];//등록자명
    $wr_write_mb_id = $config[cf_admin];//등록아이디
    $wr_write_password = sql_password(G5_SERVER_TIME);//패스워드
  
    $sql = " insert into $write_table
                set ca_name = '$wr_write[ca_name]',
                    wr_num = '$wr_write[wr_num]',
                    wr_parent = '$wr_id',
                    wr_is_comment = '1',
                    wr_comment = '1',
                    wr_content = '$wr_write_content',
                    mb_id = '$wr_write_mb_id',
                    wr_password = '$wr_write_password',
                    wr_name = '$wr_write_cname',
                    wr_datetime = '".G5_TIME_YMDHIS."',
                    wr_ip = '000.000.000.000' ";
    sql_query($sql);
  
  
    // 원글에 코멘트수 증가
    sql_query(" update $write_table set wr_comment = wr_comment + 1, wr_last = '".G5_TIME_YMDHIS."' where wr_id = '$wr_id' ");
    sql_query(" update {$g5['board_new_table']} set as_comment = as_comment + 1 where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
    // 코멘트 1 증가
    sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '$bo_table' ");
  
}


@include_once($write_skin_path.'/write_update.tail.skin.php');
// 목록으로 이동하기
if($w == '' && isset($is_direct) && $is_direct) {
    if ($file_upload_msg)
        alert($file_upload_msg, G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table);
    else
        goto_url(G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table);
}

?>

이 질문에 댓글 쓰기 :

답변 1

아래코드를요

$randint = mt_rand(0, count($reply)-1);

    ....

able = '$bo_table' "); 
}

 

아래 for안으로 넣어보세요.

$max_reply = rand(1,10);//1에서 10사이의 랜덤수를 저장해서 아래 루프에서 돌리게됩니다.

for($m=1;$m<=$max_reply;$m++){

    /* 여기안으로 넣우세요*/

}

 

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

회원로그인

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