[英]changing title in php on refresh using cookies
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
echo ("<p><td>$row[2]</td><td>$row[0]</td><td>$row[1]</td><td><i>$row[3]</i></td><td><a href=\"delete.php?time=$row[2]&user=$row[0]&pass=$row[1]\"><center>[x]</center></a></td></p>");
echo "</tr>";
$x++;
}
echo "</table>";
}
else
{
echo "*No Accounts*";
}
if (isset($_COOKIE['amountx'])) {
if ($_COOKIE['amountx'] < $x) {
$x = $x - $_COOKIE['amountx'];
echo "<title>'New Logs - ($x)'</title>";
}
else if ($_COOKIE['amountx'] == $x) {
echo "<title>'Logs (0)'</title>";
}
else {
setcookie("amountx", $x, time() + 60 * 60 * 24 * 30);
}
}
else {
setcookie("amountx", $x, time() + 60 * 60 * 24 * 30);
}
The title never updates but the cookie is saved. 标题永不更新,但cookie已保存。 This was in the while loop but I took it out and it still saves the cookie amount. 这是在while循环中,但是我取出来了,它仍然节省了cookie的数量。 But I can't get it to display the new title even after refreshing every 5 seconds via meta-refresh. 但是即使通过meta-refresh每5秒刷新一次,我也无法显示新标题。 How can I update the title? 如何更新标题?
Looking at the structure of your code, it appears that you're printing HTML in the <body>
tag before you're attempting to echo a different <title>
tag. 查看代码的结构,您似乎在尝试回显其他<title>
标签之前在<body>
标签中打印HTML。
You can't have a <title>
tag anywhere but within the <head>
element. 除了<head>
元素之外,您在任何地方都没有<title>
标签。
Move your <title>
code to take effect within the <head>
element, and it should work. 移动您的<title>
代码,使其在<head>
元素内生效,并且应该可以正常工作。
我删除了页面顶部的顶部<title>Page title</title>
,现在可以正常使用了,谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.