|
 |
|
ขอความกรุณาช่วยดูโค้ดและแก้โค้ดให้หน่อยนะค่ะ เป็นโค้ดเกี่ยวกับเก็บเวลาลงฐานข้อมูลค่ะ |
|
 |
|
|
 |
 |
|
show_time.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<form name="form1" method="post" action="test.php">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><table cellspacing="1" cellpadding="1">
<tr>
<td width="73"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> </font></td>
<td width="58"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">วันที่</font></div></td>
<td width="58"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">เดือน</font></div></td>
<td width="58"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">ปี
( พ.ศ. )</font></div></td>
<td width="47"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">ชั่วโมง</font></div></td>
<td width="41"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">นาที</font></div></td>
</tr>
<tr>
<td height="26"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">เวลาเริ่มกิจกรรม</font></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="start_d" id="start_d">
<option value="0">เลือก</option>
<?
for($d=1;$d<=31;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="start_m" id="start_m">
<option value="0">เลือก</option>
<?
for($d=1;$d<=12;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="start_y" id="select2">
<option value="0">เลือก</option>
<?
$Tyear=date("Y")+543;
for($d=2550;$d<=$Tyear;$d++)
{
?>
<option value="<? echo $d-543; ?>"><? echo "พ.ศ. ".$d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="start_h" id="start_h">
<option value="0">0</option>
<?
for($d=1;$d<=24;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
: </font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="start_M" id="select">
<option value="0">00</option>
<?
for($i=1;$i<=59;$i++)
{
?>
<option value="<? echo $i; ?>"><? echo $i; ?></option>
<?
}
?>
</select>
</font></strong></td>
</tr>
<tr>
<td height="26"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">เวลาจบกิจกรรม</font></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="end_d" id="end_d">
<option value="0">เลือก</option>
<?
for($d=1;$d<=31;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="end_m" id="end_m">
<option value="0">เลือก</option>
<?
for($d=1;$d<=12;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="end_y" id="end_y">
<option value="0">เลือก</option>
<?
for($d=2550;$d<=$Tyear;$d++)
{
?>
<option value="<? echo $d-543; ?>"><? echo "พ.ศ. ".$d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="end_h" id="end_h">
<option value="0">0</option>
<?
for($d=1;$d<=24;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
: </font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">
<select name="end_M" id="select">
<option value="0">00</option>
<?
for($i=1;$i<=59;$i++)
{
?>
<option value="<? echo $i; ?>"><? echo $i; ?></option>
<?
}
?>
</select>
</font></strong></td>
</tr>
<tr>
<td height="26" colspan="6"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
|
 |
 |
 |
 |
Date :
2012-02-23 14:31:42 |
By :
rungjanjira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
test.php
<?php
function DateToTimestamp($date_){
// เป็นฟังก์ชั่น ที่จะทำวันเวลาไปเป็นฟังก์ชั่น mktime
$sh_=explode("/",$date_);
$Sec_=date("s");
$timeStamp_=mktime($sh_[3],$sh_[4],$Sec_,$sh_[1],$sh_[0],$sh_[2]);
return $timeStamp_;
}
$show_start="$_POST[start_d]/$_POST[start_m]/$_POST[start_y]/$_POST[start_h]/$_POST[start_M]"; //นำค่าวันเวลาที่ เริ่มต้นมาเก็บไว้ในตัวแปร
//$show_start="2012/2/16/10/10";
$timestamp=DateToTimestamp($show_start);//แปลงค่าให้เป็นฟังก์ชั่น mktime
$show_end="$_POST[end_d]/$_POST[end_m]/$_POST[end_y]/$_POST[end_h]/$_POST[end_M]";//นำค่าวันเวลาที่ สิ้นสิ้นมาเก็บไว้ในตัวแปร
//$show_end="2012/2/16/10/11";
$timestampa=DateToTimestamp($show_end);//แปลงค่าให้เป็นฟังก์ชั่น mktime
$test=$timestampa-$timestamp; //นำเวลาเริ่ม กับสิ้นสุดมาลบกันก็จะได้เวลา ที่จะนับถ้อยหลัง
$num=$test;
$s=date("s",$num);
$m=$num/60;
echo $test=$m.":".$s;
?>
<html>
<head>
<title>Count Down</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body onLoad="begintimer()">
<script language="">
var limit="<? echo $test; ?>"
if (document.images){
var parselimit=limit.split(":")
parselimit=(parselimit[0]*60)+(parselimit[1]*1)
}
function begintimer(){
if (!document.images)
return
if (parselimit==1)
// เหตุการณ์ที่ต้องการให้เกิดขึ้น
// window.location='page.php'; ถ้าต้องการให้กระโดดไปยัง Page อื่น
alert("ขอ อ ภัยค่ะ ขณะนี้เวลาหมดแล้ว ไม่สามารถอัปโหลดได้");
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime="เวลาที่เหลือ <font color=red> "+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที "
else
if(cursec==0)
{
alert('หมดเวลาแล้วจ้า');
}
else
{
curtime="เวลาที่เหลือ <font color=red>"+cursec+" </font>วินาที "
}
document.getElementById('dplay').innerHTML = curtime;
setTimeout("begintimer()",1000)
}
}
//-->
</script>
<div id=dplay ></div>
<form name="frmTest" action="check.php">
</form>
|
 |
 |
 |
 |
Date :
2012-02-23 14:32:25 |
By :
rungjanjira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code นี้จะต้องนำไปใส่ส่วนไหนค่ะช่วยบอกที
<?
//เทคนิคส่วนตัว แปลงให้เป็นตัวเลขให้หมด แล้วเทียบเลย
$bkk= mktime(gmdate("H")+7, gmdate("i")+0, gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"));
$datetimeformat="His";
$now_time = date($datetimeformat,$bkk) ;
if($now_time>120000 && $now_time<130000){
echo "<a href='source_file'>download</a>";
}else ;
?>
|
 |
 |
 |
 |
Date :
2012-02-23 14:33:23 |
By :
rungjanjira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ส่วนไหนที่ต้องการ show หรือ hide ก็ เอา เงื่อนไขที่ว่าไปครอบไว้
เช่น
if($now_time>120000 && $now_time<130000){
echo "ส่งงานได้ <form บลาๆๆๆๆๆ>";
}else echo " หมดเขตส่งงานแล้วจ๊ะ ";
|
 |
 |
 |
 |
Date :
2012-02-23 15:34:59 |
By :
13eachz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แสดงว่าถ้าหนูมีไฟล์ทั้ง 13 ไฟล์ หนูก็ต้องสร้างเงื่อนไข 13 เงื่อนไขใช่ไหมค่ะ
|
 |
 |
 |
 |
Date :
2012-02-23 15:47:43 |
By :
rungjanjira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
13 ไฟล์ ถ้าเงื่อนไขเดียวกัน ก็ จับยัดไว้ใน if เดียวกันได้เลยจ้า
|
 |
 |
 |
 |
Date :
2012-02-23 16:01:55 |
By :
13eachz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|