如何自动更新网页的URI


How to update the URI of the webpage automatically?

我有一个名为文件的表,其中有列,如id,名称,网页,访客。表中已经有一个文件列表。现在我已经创建了新的栏目,叫做网页和访问者。网页是文件的URI,访问者是文件的反视图。问题是,我想更新网页和访客自动使用会话,但我不能。你能帮帮我吗?

<?php
session_start();
include_once"config.php";
$webpage=htmlspecialchars($_SERVER["REQUEST_URI"]);

$result=mysql_query("SELECT * FROM files WHERE webpage='$webpage'");
$num_rows = mysql_num_rows($result);
if ($num_rows == 0){
mysql_query("How to update the URI ($webpage) automatically? in the files table inside the column webpage");
}else{
if (!isset($_SESSION['webpage'])){$_SESSION['webpage'] = 0;
mysql_query("UPDATE files SET visitors=visitors+1 WHERE webpage='$webpage'");}}
?>

试试这个解决方案:

<?php
session_start();
include_once"config.php";
$webpage=htmlspecialchars($_SERVER["REQUEST_URI"]);

$result=mysql_query("SELECT * FROM files WHERE webpage='$webpage'");
$num_rows = mysql_num_rows($result);
if ($num_rows == 0)
{
    $_SESSION['webpage'][] = $webpage;
    mysql_query("INSERT INTO files (`id`,`name`,`webpage`,`visitors`) VALUES (null,'$name','$webpage','1')");
}
else
{
    if(is_array($_SESSION['webpage'])) && !in_array($webpage, $_SESSION['webpage'])))
    {
        $_SESSION['webpage'][] = $webpage;
        mysql_query("UPDATE files SET visitors=visitors+1 WHERE webpage='$webpage'");
    }
}
?>