开发者

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=\"d开发者_如何转开发elete.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. This was in the while loop but I took it out and it still saves the cookie amount. But I can't get it to display the new title even after refreshing every 5 seconds via meta-refresh. 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.

You can't have a <title> tag anywhere but within the <head> element.

Move your <title> code to take effect within the <head> element, and it should work.


I removed the top <title>Page title</title> at the top of my page now it works properly thanks guys.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜