gpt4 book ai didi

重新加载页面的php脚本

转载 作者:行者123 更新时间:2023-11-29 01:02:10 25 4
gpt4 key购买 nike

我在处理未立即显示更新数据的页面时遇到困难这是我现在的:

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("hospital", $con);

$result = mysql_query("SELECT * FROM t2");

echo"<br>";
echo"<big>All In Patients</big>";
echo "<table border='1'>
<tr>
<th>Pnum</th>
<th>HospNum</th>
<th>RoomNum</th>
<th>LastName</th>
<th>FirstName</th>
<th>MidName</th>
<th>Address</th>
<th>TelNum</th>
<th>Stat</th>
<th>Nurse</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['PNUM'] . "</td>";
echo "<td>" . $row['HOSPNUM'] . "</td>";
echo "<td>" . $row['ROOMNUM'] . "</td>";
echo "<td>" . $row['LASTNAME'] . "</td>";
echo "<td>" . $row['FIRSTNAME'] . "</td>";
echo "<td>" . $row['MIDNAME'] . "</td>";
echo "<td>" . $row['ADDRESS'] . "</td>";
echo "<td>" . $row['TELNUM'] . "</td>";
echo "<td>" . $row['STAT'] . "</td>";
echo "<td>" . $row['NURSE'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>

<form>
<input type="button" class='type_button' value="Print" onClick="window.print();" />
</form>
</body>
</html>

您是否知道可以更新上述代码的任何解决方法?因为当我更新数据然后加载上面的代码时。它只会显示尚未更新的先前数据。您必须右键单击并刷新页面才能看到效果。

最佳答案

您可以尝试设置缓存 header 。

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

或者您正在从 MySQL 中获取缓存数据?

SELECT SQL_NO_CACHE * FROM t2

关于重新加载页面的php脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2386841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com