標題:
8/6 電子商務中階班考題
[打印本頁]
作者:
may
時間:
2011-8-6 17:41
標題:
8/6 電子商務中階班考題
請設計一個表單,讓使用者可以查詢該國家的時間。
表單要包含下拉式選單,透過按鈕送出要查詢的國家時間。
作者:
may
時間:
2011-8-6 18:22
一、先到以下網站查尋時間設定的語法
http://us.php.net/manual/en/timezones.asia.php
http://www.php.net/manual/en/fun ... reviations-list.php
作者:
may
時間:
2011-8-6 18:36
標題:
makedatabase.php
<?
require("config.ini.php");
$pageArray = array(
"http://us.php.net/manual/en/timezones.africa.php",
"http://us.php.net/manual/en/timezones.america.php",
"http://us.php.net/manual/en/timezones.antarctica.php",
"http://us.php.net/manual/en/timezones.arctic.php",
"http://us.php.net/manual/en/timezones.asia.php",
"http://us.php.net/manual/en/timezones.atlantic.php",
"http://us.php.net/manual/en/timezones.australia.php",
"http://us.php.net/manual/en/timezones.europe.php",
"http://us.php.net/manual/en/timezones.indian.php",
"http://us.php.net/manual/en/timezones.pacific.php",
"http://us.php.net/manual/en/timezones.others.php"
);
foreach($pageArray as $url)
{
$area = str_replace(".php","",str_replace("http://us.php.net/manual/en/timezones.","",$url));
if($debug == "true")
echo $area."<br>";
$fp = fopen($url,"r");
while($line = fgets($fp))
{
$country = subcontent($line,"<td align=\"left\">","</td>");
if($country != "" && $country != "empty\"> ")
{
if($debug == "true")
echo $country."<br>\n";
if(mysql_num_rows(mysql_query("select * from timezonetb where area = '$area' and country = '$country'"))==0)
{
$sql = "insert into timezonetb(area,country)values('$area','$country')";
mysql_query($sql,$link);
}
}
}
fclose($fp);
}
?>
作者:
may
時間:
2011-8-6 20:20
標題:
config.ini.php
<?
function subcontent($contents,$strStart,$strEnd)
{
$start = strpos($contents,$strStart)+strlen($strStart);
$len = strpos($contents,$strEnd)-$start;
if($len > 0)
return substr($contents,$start,$len);
else
return "";
}
$link = mysql_pconnect("localhost","root","3893527");
mysql_select_db("WorldTimedb",$link);
?>
作者:
may
時間:
2011-8-7 12:34
標題:
index.php
<?
require("config.ini.php");
$changetocountry = 0;
if($area == "")
{
$area = $default_area;
}
else
{
$changetocountry = 1;
}
if($timezone == "")
{
$timezone = $default_zone;
}
//date_default_timezone_set($timezone);
$dateTimeZone = new DateTimeZone($timezone);
$dateTime = new DateTime("now", $dateTimeZone);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>世界時間顯示器</title>
<h3>世界時間顯示器</h3>
<script src="js/tagChange.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<style type="text/css">
</style>
<!-- 第一層 -->
<div id='menu'>
<ul id='nav'>
<li><a href='#' class=''>地區</a></li>
<li><a href='#' class='<?echo ($changetocountry==1?"selected":"");?>'>城市</a></li>
<li><a href='#' class='<?echo ($changetocountry==1?"":"selected");?>'>時間</a></li>
<div style="clear:both"></div>
</ul>
<!-- 第二層 -->
<div id='menu_con'>
<div class='tag' style='display:none' align=center>
<?
$sql = "select distinct area from timezonetb";
//$sql = "select area from timezonetb group by area";
$rs = mysql_query($sql);
echo "<select id=area onchange='location.href=\"index.php?area=\"+area.value'>";
echo "<option value=''>請選擇</option>";
while(list($showarea) = mysql_fetch_row($rs))
{
echo "<option value=$showarea>$showarea</option>";
}
echo "</select>";
?>
</div>
<div class='tag' style='display:<?echo ($changetocountry==1?"block":"none");?>' align=center>
<?
$sql = "select country from timezonetb where area = '$area'";
//$sql = "select area from timezonetb group by area";
$rs = mysql_query($sql);
echo "<select id=country onchange='location.href=\"index.php?timezone=\"+country.value'>";
echo "<option value=''>請選擇</option>";
while(list($country) = mysql_fetch_row($rs))
{
echo "<option value=$country>$country</option>";
}
echo "</select>";
?>
</div>
<div class='tag' style='display:<?echo ($changetocountry==1?"none":"block");?>' align=center>
<?echo $timezone?><br><span id=timedisplay></span>
</div>
</div>
</div>
<script language="JavaScript">
<!--
function check24(hour)
{
if(hour >= 24)
return hour - 24;
else if(hour < 0)
return hour + 24;
else
return hour;
}
function IfZero(num)
{
return ((num <= 9) ? ("0" + num) : num);
}
function GetTime()
{
var offset = <?echo $dateTimeZone->getOffset($dateTime)/3600;?>;
var dt = new Date();
var def = dt.getTimezoneOffset()/60;
var gmt = (dt.getHours() + def);
var ending = ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds());
var rome =check24(gmt+offset);
timedisplay.innerHTML = (IfZero(rome) + ending);
setTimeout("GetTime()", 1000);
}
GetTime();
-->
</script>
</head>
</html>
作者:
may
時間:
2011-8-7 12:36
標題:
css/style.css
body{background:#F8F8F2;}
a{color:#FA0300;}
#menu{width:360px;}
#menu #nav{display:block; width:100%; padding:0; margin:0; list-style:none;
background:url(../images/bg.gif)}
#menu #nav li {float:left; width:120px;}
#menu #nav li a{display:block; line-height:27px; text-decoration:none;
padding:0 0 0 5px; text-align:center;}
#menu_con{width:358px; height:50px; border: 1px solid #bf9666;border-top:none}
.selected{background:url(../images/tag_bg.gif)}
.clear{clear:both}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2