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.
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();
?>
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.