<meta http-equiv="refresh" content="300">
<?php
$time=date("Y-m-d H:i:s");
$up_sql="update t1 set time='$time' where id='$id'";
//id是从之前的页面传过来的
mysql_query($up_sql,$conn)or die ("更新数据失败: ".mysql_error());
?>
<?php
$time=date("Y-m-d H:i:s");
$up_sql="update t1 set time='$time' where id='$id'";
//id是从之前的页面传过来的
mysql_query($up_sql,$conn)or die ("更新数据失败: ".mysql_error());
?>
直接在数据库里面做不行吗?那就在服务器上面写个小服务
<script>
function set()
{
?????????这里怎么办?
setTimeout("sett()",300000);
}
</script>但是不清楚在函数里应该怎么写才能调用php的函数呢?
现在的问题就是 如何在JS中调用php的函数?
或者是通过别的方法来实现?
请高手赐教 谢谢大家了
function set()
{
?????????这里怎么办?
---------------
生成xmlhttp对象,xmlhttp.open("GET","处理.php",true");
---------------
setTimeout("sett()",300000);
}
</script>
function upset(){
echo"iloveu!";
}
?>
<script>
function set()
{
alert('<? upset();?>');
setTimeout('set()',3);
}
</script>
<script>set();</script>
我以前没看过ajax的东西 要去学习一下了~
要是能有xmlhttp.open具体用法的例子就好了比如调用 hello.php
hello.php的内容是
<?php
$time=date("Y-m-d");
echo "Welcome ! <br>";
echo "Today is ".$time;
?>谢谢~
function createAjax()
{
ajax = false;
try
{
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
ajax = false;
}
}
if(!ajax && typeof(XMLHttpRequest)!="undefined")
{
ajax = new XMLHttpRequest();
}
return ajax;
}URL = "1.php";
function dosth()
{
Ajax = createAjax();
Ajax.open("GET", URL, true);
Ajax.send(null);
}window.onload = function()
{
time = 1000; //以秒为单位,你自己设
setInterval("dosth()", 100);
}
</script>
PHP部分:
<?
mysql_connect("", "root", "");
mysql_select_db("zealot");
mysql_query("INSERT INTO a SET b='aaa'");
?>FF、IE6下测试通过
替换为
setInterval("dosth()", time);
应该是以毫秒为单位。差点铸成大错
- -b
雷锋阿!!!!!!!!!!
好心人 谢谢你
谢谢大家 结贴了