|
|
|
ช่วยแก้โค้ดให้หน่อยค่ะ อยากได้โค้ดนับเวลาโดยเรียกจากฐานข้อมูลค่ะจะต้องทำไงค่ะ ช่วยที |
|
|
|
|
|
|
|
Code (PHP)
<?php
$result = array();
$result[1]['ex_id'] = "1";
$result[1]['ex_name'] = "Introducing the TCP/IP Model";
$result[2]['ex_id'] = "2";
$result[2]['ex_name'] = "Introducing LANs and Their Computer";
$result[3]['ex_id'] = "3";
$result[3]['ex_name'] = "Describing Ethernet Interface";
$result[4]['ex_id'] = "4";
$result[4]['ex_name'] = "Introducing LANs and Their Computer";
$result[5]['ex_id'] = "5";
$result[5]['ex_name'] = "Describing Ethernet Interface";
$result[6]['ex_id'] = "6";
$result[6]['ex_name'] = "Introducing LANs and Their Computer";
$result[7]['ex_id'] = "7";
$result[7]['ex_name'] = "Describing Ethernet Interface";
$result[8]['ex_id'] = "8";
$result[8]['ex_name'] = "Introducing LANs and Their Computer";
$result[9]['ex_id'] = "9";
$result[9]['ex_name'] = "Describing Ethernet Interface";
$result[10]['ex_id'] = "10";
$result[10]['ex_name'] = "Introducing LANs and Their Computer";
$result[11]['ex_id'] = "11";
$result[11]['ex_name'] = "Describing Ethernet Interface";
$result[12]['ex_id'] = "12";
$result[12]['ex_name'] = "Introducing LANs and Their Computer";
$exIdReq = array();
if(count($result) > 0){
foreach($result AS $index => $value){
$exIdReq[] = $value['ex_id'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type='text/javascript' src='js/jquery.min.js'></script>
<script type='text/javascript'>
setTimeout('checkedCondition()',1000);
function checkedCondition(){
var ex_id_json = <?php echo json_encode($exIdReq); ?>;
$.getJSON("CheckExcercise.php",{ // http://api.jquery.com/jQuery.getJSON/
exIdList: ex_id_json // exIdList = parameter, ex_id_json = parameter value (json format)
}, function(data) {
$.each(data, function(){ // http://api.jquery.com/jQuery.each/
//alert("ID = " + this.id + ", STATUS = "+ this.status + ", FILE PATH = " + this.file_path);
if(this.status == "Y"){
$('#excercise_' + this.id + '_th').html('<a href="'+this.file_path+'" target="_blank"><img src="picture/PDF.png" alt="" width="32" height="32" /></a>');
// http://api.jquery.com/html/
$('#excercise_' + this.id + '_en').html('<a href="'+this.file_path+'" target="_blank"><img src="picture/PDF.png" alt="" width="32" height="32" /></a>');
//setTimeout('checkedCondition()',10000);
}else{
$('#excercise_' + this.id + '_th').html('');
$('#excercise_' + this.id + '_en').html('');
}
});
setTimeout('checkedCondition()',30000);
});
}
</script>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
.style2 {color: #0000FF}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style3 {color: #39590E}
.style4 {font-size: 14px}
-->
</style>
</head>
<body>
<table width="972" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="972"><a href="index.php"><img src="picture/index.jpg" alt="" width="960" height="200" border="0" usemap="#Map" /></a>
<map name="Map" id="Map2">
<area shape="rect" coords="77,169,144,197" href="index.php" />
<area shape="rect" coords="163,169,231,198" href="Lession.php" />
<area shape="rect" coords="308,166,446,202" href="Excercise.php" />
<area shape="rect" coords="460,170,661,199" href="ansExcercise.php" />
<area shape="rect" coords="241,162,299,200" href="slides/index/index.htm" />
</map>
<map name="Map" id="Map">
<area shape="rect" coords="582,273,688,297" href="Excercise.php" />
<area shape="rect" coords="509,274,570,295" href="Lession1.php" />
<area shape="rect" coords="381,272,452,300" href="index.php" />
</map></td>
</tr>
<tr>
<td valign="top"><center>
<table width="973" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="208" valign="top" bgcolor="#D6EDC3"><table width="208" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td colspan="2" bgcolor="#D6EDC3"><img src="picture/ppp.jpg" width="204" height="40" /></td>
</tr>
<tr valign="top" bgcolor="#D6EDC3">
<td width="18"><img src="picture/aa.jpg" width="18" height="18" /></td>
<td width="190" align="left"><span style="color: #00C; font-family: sans-serif; font-size: 14px;">ตารางเรียน</span></td>
</tr>
<tr valign="top" bgcolor="#D6EDC3">
<td><img src="picture/aa.jpg" alt="" width="18" height="18" /></td>
<td align="left"><a href="selectgroup.php"><span class="style4">ตรวจสอบรายชือ-กลุ่</span>ม</a></td>
</tr>
<tr valign="top" bgcolor="#D6EDC3">
<td><img src="picture/aa.jpg" alt="" width="18" height="18" /></td>
<td align="left"><span class="style4" style="color: #009"><a href="up/Upload1.php">ส่งการบ้าน</a></span></td>
</tr>
<tr valign="top" bgcolor="#D6EDC3">
<td><img src="picture/aa.jpg" alt="" width="18" height="18" /></td>
<td align="left"><span class="style4 style3"><a href="index.php">ออกจากระบบ</a>
<?php //logout.php
@session_start();
@session_destroy(); //ล้าง session ทุกตัว
?>
</span></td>
</tr>
<tr valign="top">
<td bgcolor="#D6EDC3"> </td>
<td bgcolor="#D6EDC3"> </td>
</tr>
</table></td>
<td width="765" valign="top"><table width="755" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="picture/ooo1.jpg" width="755" height="41" /></td>
</tr>
<tr>
<td height="31"><table width="754" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td width="42" height="36" align="center" bgcolor="#CCCCCC">บทที่</td>
<td width="556" align="center" bgcolor="#CCCCCC">แบบฝึกปฏิบัติการ</td>
<td width="70" align="center" bgcolor="#CCCCCC">ภาษาไทย</td>
<td width="86" align="center" bgcolor="#CCCCCC">ภาษาอังกฤษ</td>
</tr>
<?php
if(count($result) > 0){
$runingNumber = 1;
foreach($result AS $index => $value){
$style = "";
if($runingNumber%2 == 0){
$style = 'bgcolor="#FFFF66"';
}
?>
<tr>
<td align="center" <?php echo $style; ?>><?php echo $runingNumber; ?></td>
<td align="left" <?php echo $style; ?>><strong><?php echo $value['ex_name']; ?></a></a> </strong> <span class="style1"> </span></td>
<td align="center" <?php echo $style; ?> id="excercise_<?php echo $value['ex_id']; ?>_th"></td>
<td align="center" <?php echo $style; ?> id="excercise_<?php echo $value['ex_id']; ?>_en"></td>
</tr>
<?php
$runingNumber++;
}
}
?>
<!--
<tr>
<td align="center" bgcolor="#FFFF66">1</td>
<td align="left" bgcolor="#FFFF66"><strong>Introducing the TCP/IP Model</a></a> </strong> <span class="style1"> </span></td>
<td align="center" bgcolor="#FFFF66" id="excercise_1_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_1_en"></td>
</tr>
<tr>
<td align="center">2</td>
<td align="left"><strong>Introducing LANs and Their Compute</strong>r</a></a></td>
<td align="center" id="excercise_2_th"></td>
<td align="center" id="excercise_2_en"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF66">3</td>
<td align="left" bgcolor="#FFFF66"><strong>Describing Ethernet Interface</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_3_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_3_en"></td>
</tr>
-->
<!--
<tr>
<td align="center">4</td>
<td align="left" bgcolor="#FFFF66"><strong>Describing ARP and RARP</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_4_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_4_en"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF66">5</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring IP</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_5_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_5_en"></td>
</tr>
<tr>
<td align="center">6</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring ultipathing</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_6_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_6_en"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF66">7</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring Routing</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_7_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_7_en"></td>
</tr>
<tr>
<td align="center">8</td>
<td align="left" bgcolor="#FFFF66"><strong>IPv6</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_8_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_8_en"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF66">9</td>
<td align="left" bgcolor="#FFFF66"><strong>Describing the Transport Layer</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_9_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_9_en"></td>
</tr>
<tr>
<td align="center">10</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring DNS</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_10_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_10_en"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF66">11</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring DHCP</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_11_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_11_en"></td>
</tr>
<tr>
<td align="center">12</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring NTP</a></a></strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_12_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_12_en"></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF66">13</td>
<td align="left" bgcolor="#FFFF66"><strong>Configuring WWW</strong></td>
<td align="center" bgcolor="#FFFF66" id="excercise_13_th"></td>
<td align="center" bgcolor="#FFFF66" id="excercise_13_en"></td>
</tr>
-->
<tr>
<td valign="top"> </td>
<td> </td>
<td align="center"> </td>
<td> </td>
</tr>
<tr>
<td valign="top"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="picture/ooo1.jpg" width="755" height="41" /></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><table width="964" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="461"><img src="picture/fff.jpg" width="461" height="92" /></td>
<td width="487"><span
</tr>
</table></td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-02-28 15:24:42 |
By :
rungjanjira |
View :
944 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$sql = "select * from excercise";
$sql_query = mysql_query($sql);
$arry = mysql_feach_array($sql_query);
while($arry = mysql_feach_array($sql_query)){
$exvalue[$start_time]['start_time'] = $_GET["start_time"];
$exvalue[$stop_time]['stop_time'] = $_GET["stop_time"];
$exvalue[$file_path]['file_path'] = $_GET["file_path"];
}
$list = $_REQUEST['exIdList'];
//fake ex value to test (ให้ทำการ query มาจาก db แทน)
/*$exValue[1]['start_time'] = "03:02:00";
$exValue[1]['stop_time'] = "03:05:00";
$exValue[1]['file_path'] = "introduction.pdf";
$exValue[2]['start_time'] = "03:02:00";
$exValue[2]['stop_time'] = "03:05:00";
$exValue[2]['file_path'] = "introduction.pdf";
$exValue[3]['start_time'] = "03:02:00";
$exValue[3]['stop_time'] = "03:05:00";
$exValue[3]['file_path'] = "introduction.pdf";
*/
$currentTime = strtotime(date('H:i:s'));
$responseArray = array();
foreach($list AS $index => $value){
if($currentTime >= strtotime($exValue[$value]['start_time']) && $currentTime <= strtotime($exValue[$value]['stop_time'])){
$responseArray[$value]['id'] = $value;
$responseArray[$value]['status'] = "Y";
$responseArray[$value]['file_path'] = $exValue[$value]['file_path'];
}else{
$responseArray[$value]['id'] = $value;
$responseArray[$value]['status'] = "N";
$responseArray[$value]['file_path'] = "";
}
}
echo json_encode($responseArray);
?>
|
|
|
|
|
Date :
2012-02-28 15:25:00 |
By :
rungjanjira |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ให้ดูอะไรครับ code เยอะมาก
|
|
|
|
|
Date :
2012-02-29 17:43:47 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|