php 代码中的自动刷新不起作用
auto refresh in php code not working
我试图让自动刷新在 PHP 代码中工作。
此代码用于在 'ref docs' 下包含一篇带有博客的新闻文章,但是当您 post 发表评论时,博客表单和 postings 出现两次。刷新后恢复正常
<?php>
$template = "3.2 Ajax comments style";
$nppage = "1";
include 'index.php';
if($_GET['id']){
require_once('db.php');
require_once('config.php');
$cat = array();
$assignedcats = array();
$assignedcats = DataAccess::fetch("SELECT news30_cats.name AS catname FROM news30_groupcats
LEFT JOIN news30_cats ON news30_groupcats.catid = news30_cats.id
WHERE storyid = ?", $_GET['id']);
foreach($assignedcats AS $cats){
$cat[] = $cats['catname'];
}
$static = true;
$nppage = "5";
$template = 'ref_docs';
include 'index.php';
}
?>
所以我尝试合并以下 [ 以在执行包含代码后强制刷新。但它不起作用。任何评论想法表示赞赏。
$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");
我无法解决这个问题,如果有任何进一步的帮助,我将不胜感激。
我将我的代码分解为以下内容。这只是显示新闻文章和下面的博客。
<?php
$template = "comments style";
$nppage = "1";
include 'index.php';
?>
但是执行完这段代码后,我希望页面只刷新一次,以解决加载问题。
我已经尝试添加
<?php
$template = "comments style";
$nppage = "1";
include 'index.php';
{
$page = $_SERVER['PHP_SELF'];
$sec = "1";
header("Refresh: $sec; url=$page");
}
?>
和
<?php
$template = "comments style";
$nppage = "1";
include 'index.php';
{
$page = $_SERVER['PHP_SELF'];
$sec = "1";
header("Location: ".$page
}
?>
这些都没有用。如果有人可以提供有用的意见,我将有义务。
您可以尝试将页面重定向到自身,而不是刷新。这将看起来像用户端的刷新操作。
尝试使用
header("Location: ".$page)
其中 $page
与您使用的相同。
我试图让自动刷新在 PHP 代码中工作。
此代码用于在 'ref docs' 下包含一篇带有博客的新闻文章,但是当您 post 发表评论时,博客表单和 postings 出现两次。刷新后恢复正常
<?php>
$template = "3.2 Ajax comments style";
$nppage = "1";
include 'index.php';
if($_GET['id']){
require_once('db.php');
require_once('config.php');
$cat = array();
$assignedcats = array();
$assignedcats = DataAccess::fetch("SELECT news30_cats.name AS catname FROM news30_groupcats
LEFT JOIN news30_cats ON news30_groupcats.catid = news30_cats.id
WHERE storyid = ?", $_GET['id']);
foreach($assignedcats AS $cats){
$cat[] = $cats['catname'];
}
$static = true;
$nppage = "5";
$template = 'ref_docs';
include 'index.php';
}
?>
所以我尝试合并以下 [ 以在执行包含代码后强制刷新。但它不起作用。任何评论想法表示赞赏。
$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");
我无法解决这个问题,如果有任何进一步的帮助,我将不胜感激。
我将我的代码分解为以下内容。这只是显示新闻文章和下面的博客。
<?php
$template = "comments style";
$nppage = "1";
include 'index.php';
?>
但是执行完这段代码后,我希望页面只刷新一次,以解决加载问题。
我已经尝试添加
<?php
$template = "comments style";
$nppage = "1";
include 'index.php';
{
$page = $_SERVER['PHP_SELF'];
$sec = "1";
header("Refresh: $sec; url=$page");
}
?>
和
<?php
$template = "comments style";
$nppage = "1";
include 'index.php';
{
$page = $_SERVER['PHP_SELF'];
$sec = "1";
header("Location: ".$page
}
?>
这些都没有用。如果有人可以提供有用的意见,我将有义务。
您可以尝试将页面重定向到自身,而不是刷新。这将看起来像用户端的刷新操作。
尝试使用
header("Location: ".$page)
其中 $page
与您使用的相同。