Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于从mysql表中提取数据的php脚本的缓存选项_Php_Html_Mysql_Caching - Fatal编程技术网

用于从mysql表中提取数据的php脚本的缓存选项

用于从mysql表中提取数据的php脚本的缓存选项,php,html,mysql,caching,Php,Html,Mysql,Caching,我想知道使用什么函数来缓存拉取的数据,并在15-30分钟后刷新数据 下面是将数据从mysql拉到网站的php脚本 <?php include('mysql_connection.php'); $c = mysqlConnect(); $locale = $_GET['locale']; $last_bulletins_id = $_GET['bulletins_id']; sendQuery ("set character_set_results='utf8'"); sendQue

我想知道使用什么函数来缓存拉取的数据,并在15-30分钟后刷新数据

下面是将数据从mysql拉到网站的php脚本

<?php
include('mysql_connection.php');

$c = mysqlConnect();

$locale = $_GET['locale'];
$last_bulletins_id = $_GET['bulletins_id'];

sendQuery ("set character_set_results='utf8'"); 
sendQuery ("set collation_connection='utf8_general_ci'"); 

if(strcmp($locale,"en") != 0)
$locale = "en";
$result = sendQuery("
SELECT bulletins.id, posted_date, message, name
FROM bulletins 
LEFT JOIN players ON (bulletins.player_id = players.user_id)
WHERE bulletins.id > ".$last_bulletins_id." and locale = '".$locale."' 
ORDER BY bulletins.id DESC 
LIMIT 10");
echo '<table width=\"100%\">';
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
    echo '<tr><td width=\"100%\"><b>Date: </b>'.$row[1].'</td></tr>';
    echo '<tr><td width=\"100%\"><b>Author: </b>'.$row[3].'</td></tr>';
    echo '<tr><td width=\"100%\">'.nl2br($row[2]).'</td></tr>';
    echo '<tr><td width=\"100%\"><hr style="height: 2px; border: none; background: #515151;"></td></tr>';
}
echo '</table>';    

mysqlClose($c);

您应该将输出的数据写入缓存文件,并检查上次修改文件和加载缓存文件的时间,或者如果时间大于您设置的限制,则查询数据库并输出新结果。这些功能将方便您使用: