我一开始想在 html 中使用 php,但是我发现方法是创建 .htaccess 文件并且不起作用,所以我使用 php 编写相同的 html 然后在 php 中执行任务。我想在 html 中使用 php 的原因是我想每 10 秒将数据存储在数据库中。但是我的 html 使用 css 来设计布局,当我在 php 中使用相同的代码时,.php 文件在 IE 浏览器中不能像 html 一样工作。但是,我使用firefox和crome浏览器,效果很好。我最近使用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 无法正常工作。
它出什么问题了?
任何帮助表示赞赏!