<?php include 'connect.php'; $time = $db->prepare('SELECT result_time FROM tbl_result'); $time->execute(); while ($result_time = $time->fetchAll(PDO::FETCH_ASSOC)) { //echo $result_time['result_time']; $seconds = secondsTime($result_time['result_time']); } function secondsTime($examTime) { //แปลง x:x:x $time = explode(":", $examTime); $h = $time[0]*3600; $m = $time[1]*60; $s = $time[2]*1; $seconds = $h+$m+$s; return $seconds; //แปลงค่าเป็นวินาที } if (!isset($_SESSION['timeend'])){ unset($_SESSION['timeend']); $endtime = time() + $seconds; $_SESSION['timeend'] = $endtime; } ($_SESSION['timeend'] - time()) < 0 ? $EndTime = 0 : $EndTime = $_SESSION['timeend'] - time(); if($EndTime <= 0) { unset($_SESSION['timeend']); //session_destroy(); } $time = gmdate("H:i:s", $EndTime); //แปลงวินาทีเป็น xx:xx:xx ?> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <body onLoad="begintimer()"> <script language=""> var limit="<?=$time;?>"; if (document.images){ var parselimit=limit.split(":") parselimit=(parselimit[0]*3600)+(parselimit[1]*60)+parselimit[2]*1 //alert(parselimit); } function begintimer(){ if (!document.images) return if (parselimit==1) // เหตุการณ์ที่ต้องการให้เกิดขึ้น // window.location='page.php'; ถ้าต้องการให้กระโดดไปยัง Page อื่น frmTest.submit(); else{ parselimit-=1 curhr=parseInt((parselimit%86400)/3600); curmin=parseInt((parselimit%86400)%3600/60); cursec=parseInt(((parselimit%86400)%3600)%60); if (curhr!==0 && curmin!=0) curtime="เวลาที่เหลือ <font color=red> "+curhr+"</font> ชั่วโมง <font color=red>"+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที " else if(cursec==0 && curmin==0 && curhr==0) { alert('หมดเวลาแล้วจ้า'); } else { curtime="เวลาที่เหลือ <font color=red> "+curhr+"</font> ชั่วโมง <font color=red>"+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที " } document.getElementById('dplay').innerHTML = curtime; setTimeout("begintimer()",1000) } } //--> </script> <div id=dplay ></div>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง