duanlinghe8417 2015-06-01 17:07
浏览 16
已采纳

重新加载网页某些时间甚至没有人使用它

I want create a website certain time of the day(e.g. 9pm) will auto reload the webpage .
The main point to reload the webpage is to insert some data into database at certain time even no one viewing at the webpage.

My Idea: Database A : Everytime reach 12am , they will update all the data to 0.
Database B : Want to insert data from database A to track the old data:

INSERT INTO `report`(`updated_date`, `name`, `occupied`) VALUES ('$time','S','$arrayS[$i]')

Due to Database_A 12am will always auto update all the data to 0 , so I need to store the data to Database B. So the User will be able to view the old data.

Current Date is base on Database A and Previous data base on DatabaseB:

(image example :) http://gyazo.com/54e93de27690291a80a3be0d07868b66

I have research afew method and tried out :

1.This method only work when I was viewing the web.However after I close ,no action will be taken.

    $page = $_SERVER['PHP_SELF'];

$now = time();
$today = strtotime('12:12');
$tomorrow = strtotime('tomorrow 12:12');
if (($today - $now) > 0) {
    $refreshTime = $today - $now;
} else {
    $refreshTime = $tomorrow - $now;
}

header("Refresh: $refreshTime; url=$page"); 
  • 写回答

1条回答 默认 最新

  • dpbvpgvrhwxen3222 2015-06-01 17:11
    关注

    You can use a cron if on a linux based environment or Windows Scheduler if you're on a Windows based environment.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,