最初は html で php を使用したいのですが、.htaccess ファイルを作成する方法が見つかりませんでした。そのため、php を使用して同じ html をコーディングし、php でタスクを実行します。htmlでphpを使いたい理由は、10秒単位でデータベースにデータを格納したいからです。しかし、私の html は css を使用してレイアウトを設計しており、php で同じコードを使用すると、.php ファイルは IE ブラウザーで html として機能しません。ただし、Firefox と Chrome ブラウザを使用していますが、問題なく動作します。私は最近IE6を使用していますが、それがIEブラウザに関連しているかどうかはわかりません... HTMLの私のコードはもともと次のとおりです。
<!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=utf-8" />
<title>Welcom to My CAM</title>
<style>
#extend{
display: none; //預設為隱藏
}
#close{
display: block; //預設為顯示
}
#extend2{
display: none; //預設為隱藏
}
#close2{
display: block; //預設為顯示
}
#extend3{
display: none; //預設為隱藏
}
#close3{
display: block; //預設為顯示
}
body {
background-color: #CC6633;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
</style>
<script type="text/javascript">
//第一個參數為欲顯示的區塊,第二個參數為欲隱藏的區塊
function exchange(show,hidden){
if(document.getElementById(show).style.display = 'none'){
document.getElementById(show).style.display = 'block';
document.getElementById(hidden).style.display = 'none';
}
}
function change1_1(){
document.getElementById("img1_1").src="images/btn1_1c.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change1_2(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2c.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change1_3(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3c.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change2_1(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1c.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change2_2(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2c.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change2_3(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3c.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change3_1(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1c.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change3_2(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2c.png";
}
</script>
</head>
<body>
<form id="form1">
<div id="close">
<img src="images/btn1.png" onClick="exchange('extend','close')">
<!-- 顯示 extend 同時隱藏 close -->
</div>
<div id="extend">
<img src="images/btn1.png" onClick="exchange('close','extend')">
<a href="index4.html" target="mainFrame"><img src="images/btn1_1.png" id="img1_1" align="right" Style="border:0px solid " onClick="change1_1()"/></a>
<a href="mac.php" target="mainFrame"><img src="images/btn1_2.png" id="img1_2" align="right" Style="border:0px solid " onClick="change1_2()" /></a>
<a href="ipcam.php" target="mainFrame"><img src="images/btn1_3.png" id="img1_3" align="right" Style="border:0px solid " onClick="change1_3()" /></a>
<!-- 顯示 close 同時隱藏 extend -->
</div>
<div id="close2">
<img src="images/btn2.png" onClick="exchange('extend2','close2')">
<!-- 顯示 extend 同時隱藏 close -->
</div>
<div id="extend2">
<img src="images/btn2.png" onClick="exchange('close2','extend2')">
<a href="account.php" target="mainFrame"><img src="images/btn2_1.png" id="img2_1" align="right" Style="border:0px solid " onClick="change2_1()" /></a>
<a href="actives.php" target="mainFrame"><img src="images/btn2_2.png" id="img2_2" align="right" Style="border:0px solid " onClick="change2_2()" /></a>
<a href="index4.html" target="mainFrame"><img src="images/btn2_3.png" id="img2_3" align="right" Style="border:0px solid " onClick="change2_3()" /></a>
<!-- 顯示 close 同時隱藏 extend -->
</div>
<div id="close3">
<img src="images/btn3.png" onClick="exchange('extend3','close3')">
<!-- 顯示 extend 同時隱藏 close -->
</div>
<div id="extend3">
<img src="images/btn3.png" onClick="exchange('close3','extend3')">
<a href="index4.html" target="mainFrame"><img src="images/btn3_1.png" id="img3_1" align="right" Style="border:0px solid " onClick="change3_1()" /></a>
<a href="index4.html" target="mainFrame"><img src="images/btn3_2.png" id="img3_2" align="right" Style="border:0px solid " onClick="change3_2()" /></a>
<!-- 顯示 close 同時隱藏 extend -->
</div>
</form>
</body>
</html>
cssを使って非表示/表示できるメニューを行うだけで、IEで正常に動作します。そしてphpと組み合わせるために、私のphpコードは次のとおりです。
<?php
//--------------------------------------------------------------------------
// 1) Connect to mysql database
//--------------------------------------------------------------------------
include "./databases.php";
//echo $_POST["selectmenu"]."test";
//--------------------------------------------------------------------------
// 2) Query database for data
//--------------------------------------------------------------------------
$result = mysql_query('select * from user ;'); //;needed!
if(!$result){
echo 'Execute SQL failed : ' . mysql_error();
exit;
}
?>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
#extend{
display: none; //預設為隱藏
}
#close{
display: block; //預設為顯示
}
#extend2{
display: none; //預設為隱藏
}
#close2{
display: block; //預設為顯示
}
#extend3{
display: none; //預設為隱藏
}
#close3{
display: block; //預設為顯示
}
body {
background-color: #CC6633;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
</style>
<script type="text/javascript">
//第一個參數為欲顯示的區塊,第二個參數為欲隱藏的區塊
function exchange(show,hidden){
if(document.getElementById(show).style.display = 'none'){
document.getElementById(show).style.display = 'block';
document.getElementById(hidden).style.display = 'none';
}
}
function change1_1(){
document.getElementById("img1_1").src="images/btn1_1c.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change1_2(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2c.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change1_3(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3c.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change2_1(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1c.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change2_2(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2c.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change2_3(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3c.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change3_1(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1c.png";
document.getElementById("img3_2").src="images/btn3_2.png";
}
function change3_2(){
document.getElementById("img1_1").src="images/btn1_1.png";
document.getElementById("img1_2").src="images/btn1_2.png";
document.getElementById("img1_3").src="images/btn1_3.png";
document.getElementById("img2_1").src="images/btn2_1.png";
document.getElementById("img2_2").src="images/btn2_2.png";
document.getElementById("img2_3").src="images/btn2_3.png";
document.getElementById("img3_1").src="images/btn3_1.png";
document.getElementById("img3_2").src="images/btn3_2c.png";
}
</script>
</head>
<body>
<form id="form1">
<div id="close">
<img src="images/btn1.png" onClick="exchange('extend','close')">
<!-- 顯示 extend 同時隱藏 close -->
</div>
<div id="extend">
<img src="images/btn1.png" onClick="exchange('close','extend')">
<a href="index4.html" target="mainFrame"><img src="images/btn1_1.png" id="img1_1" align="right" Style="border:0px solid " onClick="change1_1()"/></a>
<a href="mac.php" target="mainFrame"><img src="images/btn1_2.png" id="img1_2" align="right" Style="border:0px solid " onClick="change1_2()" /></a>
<a href="ipcam.php" target="mainFrame"><img src="images/btn1_3.png" id="img1_3" align="right" Style="border:0px solid " onClick="change1_3()" /></a>
<!-- 顯示 close 同時隱藏 extend -->
</div>
<div id="close2">
<img src="images/btn2.png" onClick="exchange('extend2','close2')">
<!-- 顯示 extend 同時隱藏 close -->
</div>
<div id="extend2">
<img src="images/btn2.png" onClick="exchange('close2','extend2')">
<a href="account.php" target="mainFrame"><img src="images/btn2_1.png" id="img2_1" align="right" Style="border:0px solid " onClick="change2_1()" /></a>
<a href="actives.php" target="mainFrame"><img src="images/btn2_2.png" id="img2_2" align="right" Style="border:0px solid " onClick="change2_2()" /></a>
<a href="index4.html" target="mainFrame"><img src="images/btn2_3.png" id="img2_3" align="right" Style="border:0px solid " onClick="change2_3()" /></a>
<!-- 顯示 close 同時隱藏 extend -->
</div>
<div id="close3">
<img src="images/btn3.png" onClick="exchange('extend3','close3')">
<!-- 顯示 extend 同時隱藏 close -->
</div>
<div id="extend3">
<img src="images/btn3.png" onClick="exchange('close3','extend3')">
<a href="index4.html" target="mainFrame"><img src="images/btn3_1.png" id="img3_1" align="right" Style="border:0px solid " onClick="change3_1()" /></a>
<a href="index4.html" target="mainFrame"><img src="images/btn3_2.png" id="img3_2" align="right" Style="border:0px solid " onClick="change3_2()" /></a>
<!-- 顯示 close 同時隱藏 extend -->
</div>
</form>
<?
header("Refresh:10");
$handle=fopen("userfile.txt","w+");
$content="";
if($handle)
{
while( $rows = mysql_fetch_array($result)){
$userId = $rows[userId];
$userMail = $rows[userMail];
$content.=$userId.";".$userMail.";";
}
$num=fwrite($handle, $content);
fclose($handle);
#echo $num;
}
else
{
echo "There is something wrong.";
}
?>
</body>
</html>
最初にデータベースに接続し、<body>
部分的に、データを保存するための php コードを実行します。
データをうまく保存できますが、IE の UI は機能しません。
どうしたの?
どんな助けでも感謝します!