dsakktdog498483070 2015-01-18 20:11
浏览 73
已采纳

使用php(?)以每个服务器日的数量随机增加数值

Looking for breadcrumbs/hints on a project I've found in my lap. I typically work in pure HTML/CSS with sprinkles of basic PHP/Javascript. Usually if someone sends me in the right direction I can piece things together.

My client wants a ticker that updates every SERVER DAY. For Example:
1. Value X is set to 100
2. check if 24 hours (SERVER time, not client time) has passed
3. Run number generator between 5-10. Store in value Y
4. Update value X to X+Y. Re-store as value X
5. Return to step 2

I have searched this problem a couple different places but haven't quite found the direction I'm looking for. This question was close: javascript, increase number day by day

and led me to believe PHP might be my language of choice...but I'm finding more information geared towards this question written in javascript and stored client-side in cookies, which wasn't really what we were going for.

Does anyone have any ideas to get me started in the right direction? Doesn't seem to hard logically, just need to figure out the semantics. Any help is super appreciated....

UPDATE:

I've decided to use wordpress cron and found the handy wordpress crontrol plugin. This fixes the TIME issue, and thanks to 'Misunderstood's help I think I've got that file opening/random number thing down. Now what I am curious about is how to make a line of text on the site itself (could be div, h1, whatever) display the contents of the txt file 24/7. I used to know how to do this but it's escaping me. Do I need to use AJAX or javascript?

  • 写回答

2条回答 默认 最新

  • dsorecdf78171 2015-01-18 20:27
    关注

    Run a cron job that calls a php script every 24 hours at what ever time you want that to be.

    $fp = fopen('x.txt','r+');
    $x = intval(fread($fp));
    $y = mt_rand (1,5);
    fwrite($fp,$y + $x);
    fclose($fp);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?