Tom*_*ger 1 html php page-refresh
我正在努力刷新我的页面,因为我随机化了我的数据库的顺序,但是当我通过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>";
?>
Run Code Online (Sandbox Code Playgroud)
如你所见,我目前正在使用<a href='javascript:location.reload();'>,但我也尝试过javascript:window.location.href=window.location.href内部href
小智 5
使用html4
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
Run Code Online (Sandbox Code Playgroud)
用php
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0");
Run Code Online (Sandbox Code Playgroud)