php 静态页面中显示动态内容
2009-08-14 00:00
706 查看
最近在做一个站点时,需要生成静态页面,但是生成的静态页面中有些内容是需要动态获取的,怎不能每天生成一下吧。。
最后上网查了一下,再加上个要总结,呵。。。。终于实现了。。发出来,大家一起研究。。呵。。。
<span class="STYLE1">应用一</span>:文章计数,获取动态内容
计数页:count.php
静态页面mk.html中加入即可
<script src="count.php?id=<?=$id?>"></script>
切记:页面路径,生成静态后计数文件路径会变。。
<span class="STYLE1">应用二</span>:获取此页面中一些动态信息,例如相关文章之类
同样,静态页面中的链接还是此种形式
read.php里内容如下:
还有另外一种方法:
static side:
最后上网查了一下,再加上个要总结,呵。。。。终于实现了。。发出来,大家一起研究。。呵。。。
<span class="STYLE1">应用一</span>:文章计数,获取动态内容
计数页:count.php
<?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?>"></script>
切记:页面路径,生成静态后计数文件路径会变。。
<span class="STYLE1">应用二</span>:获取此页面中一些动态信息,例如相关文章之类
同样,静态页面中的链接还是此种形式
<script src="read.php?cid=<?=$A['code']?>"></script>
read.php里内容如下:
<?php $cid=$_GET['cid']; ?> document.write("<TABLE cellSpacing=1 cellPadding=8 width=100% bgColor=#c4cbce border=0>"); document.write("<TR bgColor=#ffffff align=center>"); document.write("<TD width=33% align=center bgcolor=#ffffff>订单号</TD>"); document.write("<TD>年级科目</TD>"); document.write("<TD>时间</TD>"); document.write("</TR>"); <?php $succquery=$DB->query("select * from ".$tablepre."test where cid='$cid'"); while($succ=$DB->fetch_array($succquery)) { ?> document.write("<TR bgColor=#ffffff align=center>"); document.write("<TD><?=$succ['id']?></TD>"); document.write("<TD><?=$succ['city']?></TD>"); document.write("<TD><?=date('Y-m-d H:i:s',$succ['addtime'])?></TD>"); document.write("</TR>"); <?php } ?> document.write("</TABLE>"); document.write("<br>");
还有另外一种方法:
static side:
<html><body> <script> function fill_in(html) { document.getElementById('into').innerHTML = html; } </script> <div id="into"></div> <iframe name="dynamic" src="dynamic.html" style="width:0px;height:0px:frame-border:none;display:none;"></iframe> </body></html> dynamic page: <html><body> <div id="content">fill in any thing that is dynamic without document.write()</div> <script> var html = document.getElementById('content').innerHTML; parent.fill_in(html); document.getElementById('content').innerHTML = ""; </script> </body></html>
相关文章推荐
- php 静态页面中显示动态内容
- 原生js根据url参数动态显示静态页面内容
- 静态页面中显示动态内容,一些网站的qq在线状态,还有购物车用的是这个方法
- 使PHP页面静态化技术,php动态页面转html静态页面
- js+php简单实现下载页面中当前显示的表格内容
- php页面静态化—动态页面和静态页面
- Pega How To系列之一:如何在页面上动态显示/隐藏内容 ----CheneyWang
- 【phpcms-v9】content_form.calss.php文件分析-内容添加页面动态表单的生成原理
- 在php页面中显示数据库内容时,中文显示乱码
- php将动态页面缓存为静态html原理
- php 获取用textarea保存到数据库的内容,显示到页面保持换行
- nodejs之获取客户端真实的ip地址+动态页面中引用静态路径下的文件及图片等内容
- php 获取用textarea保存到数据库的内容,显示到页面保持换行
- PHP动态加载html文件之后<head>中内容全部移动到<body>中导致页面头部存在空白
- 【phpcms-v9】content_form.calss.php文件分析-内容添加页面动态表单的生成原理
- 使用PHP向Mysql数据库插入信息,页面中文内容显示正常,但在数据库里却是乱码,这个怎么解决?
- php读取动态页面生成静态html文件的方法
- 根据后台配置项,动态的在页面先控制显示内容
- 【原创】php将form表单多次请求的内容保存到txt并显示到form所在的页面
- 一个PHP一直执行的例子 不会计划任务可以用这个 PHP+jquery前台动态显示数据库内容