PHP   发布时间:2019-11-18  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php 静态页面中显示动态内容大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

最近在做一个站点时,需要生成静态页面,但是生成的静态页面中有些内容是需要动态获取的,怎不能每天生成一下吧。。
最后上网查了一下,再加上个要总结,呵。。。。终于实现了。。发出来,大家一起研究。。呵。。。
<span class="STYLE1">应用一:文章计数,获取动态内容
计数页:count.php
<div class="codetitle"><a style="cursOR: pointer" data="95780" class="copybut" id="copybut95780" onclick="doCopy('code95780')"> 代码如下:

<div class="codebody" id="code95780">
<?php
require_once './global.php';
$DB->query("update ".$tablepre."teacher set views=views+1 where id='".$_GET['id']."'");
$Hello=$DB->fetch_one_array("SELEct from ".$tablepre."teacher where id='".$_GET['id']."'");
$hcount=$Hello['views'];
?>
document.write("<?=$hcount?>");

静态页面mk.html中加入即可
<script src="count.php?id=<?=$id?>">
切记:页面路径,生成静态后计数文件路径会变。。
<span class="STYLE1">应用二:获取此页面中一些动态信息,例如相关文章之类
同样,静态页面中的链接还是此种形式
<div class="codetitle"><a style="cursOR: pointer" data="87494" class="copybut" id="copybut87494" onclick="doCopy('code87494')"> 代码如下:
<div class="codebody" id="code87494">
<script src="read.php?cid=<?=$A['code']?>">

read.php里内容如下:
<div class="codetitle"><a style="cursOR: pointer" data="65468" class="copybut" id="copybut65468" onclick="doCopy('code65468')"> 代码如下:
<div class="codebody" id="code65468">
<?php
$cid=$_GET['cid'];
?>
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
<?php
$sucCQuery=$DB->query("SELEct from ".$tablepre."test where cid='$cid'");
while($succ=$DB->fetch_array($sucCQuery))
{
?>
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
<?php
}
?>
document.write("
订单号 年级科目 时间
<?=$succ['id']?> <?=$succ['city']?> <?=date('Y-m-d H:i:s',$succ['addtime'])?>
");
document.write("
");

还有另外一种方法:
static side:
<div class="codetitle"><a style="cursOR: pointer" data="4989" class="copybut" id="copybut4989" onclick="doCopy('code4989')"> 代码如下:<div class="codebody" id="code4989">


<div id="into">
<iframe name="dynamic" src="dynamic.html" style="width:0px;height:0px:frame-border:none;display:none;">

dynamic page:

<div id="content">fill in any thing that is dynamic without document.write()


大佬总结

以上是大佬教程为你收集整理的php 静态页面中显示动态内容全部内容,希望文章能够帮你解决php 静态页面中显示动态内容所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。