dqu92800 2012-07-02 01:21
浏览 135

我需要每隔10秒用PHP提取数据

I set up a very small (internal) dedicated web server, and I need to pull some energy data every 10 seconds or so from an XML file. This is the PHP code I have thus far:

 <?php 
    $mydata = simplexml_load_file('http://192.168.x.xx:yyy/data.xml');

    echo $mydata->device[0]->name;
    echo $mydata->device[0]->value;
 ?>

I tested similar code out on my web server and PHP is installed and I think this should work, but I'd like to have this run every 10 seconds or so. This way the data displaying on my web page is always up to date. The web page will be left running 24/7 as a sign on the wall. What's the easiest way to refresh the data?

  • 写回答

4条回答 默认 最新

  • douwu8251 2012-07-02 01:23
    关注

    I would simply refresh the portion of the web page that displays the data using Ajax. Trigger the refresh using a JavaScript timer.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度