0

我有一个函数和一个更新查询,如下所示:

//Article Function
function article()
{
    if($_GET['action'] == "article" && !empty($_GET['id']))
    {
        $id = intval($_GET['id']);
        $article = array();
        $selectArticle = mysql_query("SELECT * FROM articles WHERE id='$id'");
        $rowArticle = mysql_fetch_array($selectArticle);

        $id = $rowArticle['id'];
        $title = stripcslashes($rowArticle['title']);
        $category = stripcslashes($rowArticle['category']);
        $image = stripcslashes($rowArticle['image']);
        $description = stripcslashes($rowArticle['description']);
        $full_description = stripcslashes($rowArticle['full_description']);
        $keywords = stripcslashes($rowArticle['keywords']);
        $url = "/article/" . $rowArticle['id'] . "/" . str_replace(" ","-",stripcslashes($rowArticle['title']));
        $article = array('id' => $id, 'title' => $title, 'category' => $category, 'image' => $image, 'description' => $description, 'full_description' => $full_description, 'keywords' => $keywords, 'url' => $url);
        mysql_query("UPDATE articles SET visits=visits+1 WHERE id='7'");
    }
    return $article;
}

该函数仅调用一次,但当我刷新页面时查询会运行多次。

例如,在第一次加载时访问列是 24,刷新后访问列是 48 !!!!!!

我不明白为什么我搞混了

4

1 回答 1

-1

1..使用标题并重定向页面。

   header("Location:your_page.php"); 

2..您可以重定向到同一页面或不同的页面。

   Unset $_POST after inserting it to Database.
   unset($_POST);
于 2013-06-19T20:41:43.793 回答