【发布时间】:2016-09-16 04:16:47
【问题描述】:
我正在尝试硬刷新我的页面,因为我随机化了我的数据库的顺序,但是当我通过 html 按钮刷新页面时它不起作用,直到过了一段时间。我认为这是由于网络浏览器的缓存。如果我通过 f5 刷新它也不起作用,但如果我使用 shift+f5 则它可以工作。
<?php
if(isset($_GET["genre"])) {
$db = mysqli_connect("localhost","localhost","","test","3306");
$genre = $_GET["genre"];
$sql = "SELECT tittel, aar, id, genre, plot FROM gruppe3_film WHERE genre LIKE '%$genre%' ORDER BY RAND()";
$resultat = mysqli_query($db, $sql);
$rad = mysqli_fetch_assoc($resultat);
$tittel = $rad['tittel'];
$aar = $rad['aar'];
$id = $rad['id'];
$plot = $rad['plot'];
echo "
<h2>$tittel ($aar)</h2>
<br><a href='javascript:location.reload();'><img src='../image/DBFilmCover/$id.jpg'></a>
<h4>$plot</h4>
<hr><button><a href='javascript:location.reload();'><div class='black'>New Random $genre Movie</div></a></button>";
?>
如你所见,我目前使用 <a href='javascript:location.reload();'>,但我也尝试过在 href 中使用 javascript:window.location.href=window.location.href
【问题讨论】:
-
您需要清除缓存。查看stackoverflow.com/questions/1037249/…了解更多信息
-
非常感谢,确实有效
-
没问题先生! ;)
标签: php html page-refresh