Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript exe脚本或文件的30秒倒计时_Javascript_Php_Jquery_Timer - Fatal编程技术网

Javascript exe脚本或文件的30秒倒计时

Javascript exe脚本或文件的30秒倒计时,javascript,php,jquery,timer,Javascript,Php,Jquery,Timer,我有一个php文件,当它收到来自internet的调用时运行,它从http请求捕获数据并存储在Mysql数据库中。它在后台运行 我想添加一个倒计时计时器,如果我的系统中的一个状态不为true,它将运行一个脚本,如果为true,它将运行另一个脚本。 我更喜欢服务器端的东西 我的php文件: require("config.php"); $doors=$_GET['doors']; if (func == true) { mysql_connect(localhost,$username

我有一个php文件,当它收到来自internet的调用时运行,它从http请求捕获数据并存储在Mysql数据库中。它在后台运行 我想添加一个倒计时计时器,如果我的系统中的一个状态不为true,它将运行一个脚本,如果为true,它将运行另一个脚本。 我更喜欢服务器端的东西

我的php文件:

require("config.php");

$doors=$_GET['doors'];

if (func == true) {
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");

    $query = "INSERT INTO `futelldus_doors`(`id`, `event`, `date`, `time`) VALUES ('','$doors',NOW(),NOW())";
    mysql_query($query);

    mysql_close();
} else {
    // Run timer 30 seconds countdown and then run another script or function 
}
这是倒计时功能,我搞不懂! 如何将该函数添加到我的文件/脚本中?

Well
sleep(30)可能会这样做。但你确定这就是你想要的吗?因为呼叫浏览器会在那里停留30秒?也许最好在ToDo表中添加一行,并创建一个每30秒运行一次的cron作业,以查询ToDo表中要做的事情。是否在“else”之后使用sleep(30),然后使用我的脚本函数。如果呼叫浏览器保持不变,这并不重要。我试试看,谢谢