PHP 롤링 복권 코드

不言
풀어 주다: 2023-03-24 19:50:02
원래의
2239명이 탐색했습니다.


이 기사에서는 특정 참조 가치가 있는 PHP 롤링 복권 코드를 소개합니다. 이제 모든 사람과 공유합니다. 도움이 필요한 친구들은 참조할 수 있습니다.

페이지:


<table style="width: 100%"   cellpadding="2" cellspacing="1" border="0">
		<colgroup>
			<col style="width: 30%"/>
			<col style="width: 70%"/>
		</colgroup>
		<tr>
			<td colspan="2" style="text-align: center">
				<br>
			</td>
		</tr>
		<tr style="display: none;" id="content" >
			<td colspan="2" style="font-size:40px;text-align: center;">
				<p  id="roll" style="width:100%;height:50%;font-weight: bold;margin-top:7.1%">

				</p>
			</td>
		</tr>
		<tr id="imgbut">
			<td colspan="2" style="text-align: center" >
				<p style="height: 50%">
					<img src="/oa/public/css/img/prize.png" id="start" style="width:50%;height:360px">
				</p>
			</td>
		</tr>
</table>
로그인 후 복사

js 코드:


<script type="text/javascript">
	$(function(){
		var _gogo;
		var start_btn = $("#start");
		start_btn.click(function(){
			time=0;
			$.getJSON(&#39;/oa/public/index.php/staffinfo/question/getdata/&#39;,function(json){
				if(json){
					var obj = eval(json);//将JSON字符串转化为对象
					var len = obj[&#39;ids&#39;].length;
					_gogo = setInterval(function(){
						var numrand = getRandomArrayElements(obj[&#39;ids&#39;],5);//获取随机数
						var text=&#39;&#39;;
						time+=1;
						for (var i=0;i<numrand.length;i++)
						{
							text+=&#39;<span class="realname" style="margin-left: 25%;float: left;color: 2a475c;">&#39;+obj[&#39;question&#39;][numrand[i]][&#39;realname&#39;]+&#39;</span><span class="phone" style="margin-right: 25%; float: right;color: orangered;">    &#39;+obj[&#39;question&#39;][numrand[i]][&#39;phone&#39;]+"</span><br><br>"
						}
						$("#roll").html(text);
						if(time>500){
							clearInterval(_gogo);
						}
					},1); //每隔0.1秒执行一次
					start_btn.hide();
					$("#content").css(&#39;display&#39;,&#39;&#39;);
				}else{
					$("#roll").html(&#39;系统找不到数据源,请先导入数据。&#39;);
				}
			});
		});
	});
	function getRandomArrayElements(arr, count) {
		var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
		while (i-- > min) {
			index = Math.floor((i + 1) * Math.random());
			temp = shuffled[index];
			shuffled[index] = shuffled[i];
			shuffled[i] = temp;
		}
		return shuffled.slice(min);
	}

</script>
로그인 후 복사

컨트롤러:

public function tvshowAction(){
		$prize = $this->_request->get(&#39;prize&#39;);
		$this->view->prize=$prize;
	}
public  function getdataAction() {
		global $db;
		$ids = $db->fetchCol(&#39;SELECT id FROM oa_user_question WHERE id IN (SELECT min(id) FROM oa_user_question GROUP BY phone) and is_show=1; &#39;);
		$questions = $db->fetchAll(&#39;select * from oa_user_question where is_show=1&#39;);
		$arr=array();
		foreach($questions as $question){
			$question[&#39;realname&#39;]=mb_strlen($question[&#39;realname&#39;])>8?(substr($question[&#39;realname&#39;],0,8).&#39;...&#39;):$question[&#39;realname&#39;];
			$question[&#39;realname&#39;]=iconv(&#39;gbk&#39;, &#39;utf-8&#39;, $question[&#39;realname&#39;]);
			foreach($ids as $id){
				if($question[&#39;id&#39;]==$id){
					$arr[$id]=$question;
				}
			}
		}
		$result=array(
			&#39;ids&#39;=>$ids,
			&#39;question&#39;=>$arr
		);
		echo json_encode($result );
		die;
	}
로그인 후 복사

관련 권장 사항:

PHP 롤링 로그 코드 구현

위 내용은 PHP 롤링 복권 코드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!