dongshi7350 2013-12-03 18:12
浏览 36
已采纳

MySQL表上次更新时如何显示PHP页面?

I have a MySQL db, table with data that loads from a source every 2 - 4 hours, I am currently typing when the table was last updated. Currently it is updated with load data local infile replace into mytable so the data loads automatically with cron, I just want to display below the html table when the data was last updated.

enter image description here

I have tried update_time and information.schema, but doesn't display anything it just displays blank in the area I would like it to appear.

Here is a query I have tried which seems simplest, and preferable, but only displays BLANK white page.

<?php 
    $connection = mysql_connect('host', 'user', 'password'); 
    mysql_select_db('db'); 
    $query= "SHOW TABLE STATUS LIKE 'count_page'"; $result=mysql_query($query);
    if (mysql_num_rows($results)> 0) {  
        $rst=mysql_fetch_arry($result); print $rst['Update_time']; 
    } else {
        print 'These arent the droids youre looking for'; 
    } 
    mysql_close(); 
?>
  • 写回答

1条回答 默认 最新

  • dongzhuang6177 2013-12-03 18:24
    关注

    You can make text file which contains the last updated date. Add this to your cron file:

    file_put_contents('date.txt', date('m/d/Y/g:iA'));
    

    Then put this to your table showing script where you want to add last updated date.

    echo '<b>Data Last Updated : (' . file_get_contents("date.txt") . ')</b>';
    

    You can always put extra timestamp column to your table and use it, but this is one approach.

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

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么