랜덤으로 불러오는 소스 질문좀드립니다 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

랜덤으로 불러오는 소스 질문좀드립니다 정보

랜덤으로 불러오는 소스 질문좀드립니다

본문

★1
<?=rims_latest('index_F1')?>

★2
<?=rims_latest('index_F2')?>

★3
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 728*90 -->
<ins class="adsbygoogle"
    style="display:inline-block;width:728px;height:90px"
    data-ad-client="ca-pub-1111111111111111"
    data-ad-slot="1111111111"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>



첫번째와 두번째꺼는 최신글 불러오는소스이고

3번째는 구글애드센스 소스입니다

셋중에 하나씩 랜덤으로 출력되게 하고싶은데요

코드좀 알려주시면 감사하겠습니다,.

댓글 전체

$randpix = rand(1,3);

switch ($randpix)
{
case 1:
echo rims_latest('index_F1');
break;

case 2:
echo rims_latest('index_F2');
break;

case 3:
echo "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<!-- 728*90 -->
<ins class=\"adsbygoogle\"
    style=\"display:inline-block;width:728px;height:90px\"
    data-ad-client=\"ca-pub-1111111111111111\"
    data-ad-slot=\"1111111111\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
break;
}

이런 식으로 하시면 됩니다.
<?
$randpix = rand(1,3);

switch ($randpix)
{
case 1:
echo rims_latest('index_F1');
break;

case 2:
echo rims_latest('index_F2');
break;

case 3:
echo "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<!-- 728*90 -->
<ins class=\"adsbygoogle\"
    style=\"display:inline-block;width:728px;height:90px\"
    data-ad-client=\"ca-pub-1111111111111111\"
    data-ad-slot=\"1111111111\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
break;
}


?>

이렇게 입력했는데

Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '$' in /home/hosting_users/tmdrhks0112/www/skin/board/basic/view.skin.php on line 257



라고 오류가 나오네요;
<!-- 728*90 -->
<ins class=\"adsbygoogle\"
    style=\"display:inline-block;width:728px;height:90px\"
    data-ad-client=\"ca-pub-1111111111111111\"
    data-ad-slot=\"1111111111\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
break;

작성해주신 소스에서 오류가납니다

echo  사이에 스크립트가 들어가서 생기는오류같습니다
일단 php 로 ★1  ★2  ★3 을 다 불러오신 후,

jQuery 로 random 하게 보여주는 편법? 꼼수? 는 어떠신가요?

this.randomcase = function(){
var length = $("#case li").length;
var ran = Math.floor(Math.random()*length) + 1;
$("#case li:nth-child(" + ran + ")").show();
};

$(document).ready(function(){
randomcase();
});

 저도 동일한 상황에서 제가 사용하는 php random 스크립트가 parse error 를 뿜어내서 해결봤던 꼼수 입니다. (불려와지는 내용에 자스가 포함되니까 에러를 뿜더라구요.)

이런 해결책이 맘에 드시지 않을지도... 단지 저는 현실적인 해결책이 필요했어서, 이렇게 했었습니다.
전체 67 |RSS
그누4 질문답변 내용 검색

회원로그인

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