php 靜態(tài)頁(yè)面中顯示動(dòng)態(tài)內(nèi)容
更新時(shí)間:2009年08月14日 17:04:25 作者:
靜態(tài)頁(yè)面中顯示動(dòng)態(tài)內(nèi)容,一些網(wǎng)站的qq在線(xiàn)狀態(tài),還有購(gòu)物車(chē)用的是這個(gè)方法
最近在做一個(gè)站點(diǎn)時(shí),需要生成靜態(tài)頁(yè)面,但是生成的靜態(tài)頁(yè)面中有些內(nèi)容是需要?jiǎng)討B(tài)獲取的,怎不能每天生成一下吧。。
最后上網(wǎng)查了一下,再加上個(gè)要總結(jié),呵。。。。終于實(shí)現(xiàn)了。。發(fā)出來(lái),大家一起研究。。呵。。。
<span class="STYLE1">應(yīng)用一</span>:文章計(jì)數(shù),獲取動(dòng)態(tài)內(nèi)容
計(jì)數(shù)頁(yè):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?>");
靜態(tài)頁(yè)面mk.html中加入即可
<script src="count.php?id=<?=$id?>"></script>
切記:頁(yè)面路徑,生成靜態(tài)后計(jì)數(shù)文件路徑會(huì)變。。
<span class="STYLE1">應(yīng)用二</span>:獲取此頁(yè)面中一些動(dòng)態(tài)信息,例如相關(guān)文章之類(lèi)
同樣,靜態(tài)頁(yè)面中的鏈接還是此種形式
<script src="read.php?cid=<?=$A['code']?>"></script>
read.php里內(nèi)容如下:
<?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>訂單號(hào)</TD>");
document.write("<TD>年級(jí)科目</TD>");
document.write("<TD>時(shí)間</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>
最后上網(wǎng)查了一下,再加上個(gè)要總結(jié),呵。。。。終于實(shí)現(xiàn)了。。發(fā)出來(lái),大家一起研究。。呵。。。
<span class="STYLE1">應(yīng)用一</span>:文章計(jì)數(shù),獲取動(dòng)態(tài)內(nèi)容
計(jì)數(shù)頁(yè):count.php
復(fù)制代碼 代碼如下:
<?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?>");
靜態(tài)頁(yè)面mk.html中加入即可
<script src="count.php?id=<?=$id?>"></script>
切記:頁(yè)面路徑,生成靜態(tài)后計(jì)數(shù)文件路徑會(huì)變。。
<span class="STYLE1">應(yīng)用二</span>:獲取此頁(yè)面中一些動(dòng)態(tài)信息,例如相關(guān)文章之類(lèi)
同樣,靜態(tài)頁(yè)面中的鏈接還是此種形式
復(fù)制代碼 代碼如下:
<script src="read.php?cid=<?=$A['code']?>"></script>
read.php里內(nèi)容如下:
復(fù)制代碼 代碼如下:
<?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>訂單號(hào)</TD>");
document.write("<TD>年級(jí)科目</TD>");
document.write("<TD>時(shí)間</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:
復(fù)制代碼 代碼如下:
<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>
您可能感興趣的文章:
- html靜態(tài)頁(yè)面調(diào)用php文件的方法
- PHP生成HTML靜態(tài)頁(yè)面實(shí)例代碼
- 使用PHP實(shí)現(xiàn)生成HTML靜態(tài)頁(yè)面
- 比較詳細(xì)PHP生成靜態(tài)頁(yè)面教程
- php 生成靜態(tài)頁(yè)面的辦法與實(shí)現(xiàn)代碼詳細(xì)版
- 談PHP生成靜態(tài)頁(yè)面分析 模板+緩存+寫(xiě)文件
- js+php實(shí)現(xiàn)靜態(tài)頁(yè)面實(shí)時(shí)調(diào)用用戶(hù)登陸狀態(tài)的方法
- PHP偽靜態(tài)頁(yè)面函數(shù)附使用方法
- PHP采集靜態(tài)頁(yè)面并把頁(yè)面css,img,js保存的方法
- php生成靜態(tài)頁(yè)面并實(shí)現(xiàn)預(yù)覽功能
相關(guān)文章
計(jì)算一段日期內(nèi)的周末天數(shù)的php代碼(星期六,星期日總和)
算法沒(méi)什么難點(diǎn),核心思想就是將這個(gè)時(shí)間段調(diào)整為7的整數(shù),然后乘以2,在減去或加上多算和少算的周六或周日,得到的就是星期六和星期日的總和。2009-11-11
PHP+redis實(shí)現(xiàn)微博的拉模型案例詳解
這篇文章主要介紹了PHP+redis實(shí)現(xiàn)微博的拉模型案例,結(jié)合具體實(shí)例形式詳細(xì)分析了php+redis獲取關(guān)注人最新信息的相關(guān)原理與操作技巧,需要的朋友可以參考下2019-07-07
簡(jiǎn)單的移動(dòng)設(shè)備檢測(cè)PHP腳本代碼
簡(jiǎn)單的移動(dòng)設(shè)備檢測(cè)PHP腳本代碼,需要的朋友可以參考下。2011-02-02
php數(shù)組函數(shù)序列 之a(chǎn)rray_count_values() 統(tǒng)計(jì)數(shù)組中所有值出現(xiàn)的次數(shù)函數(shù)
array_count_values() 函數(shù)用于統(tǒng)計(jì)數(shù)組中所有值出現(xiàn)的次數(shù),本函數(shù)返回一個(gè)數(shù)組,其元素的鍵名是原數(shù)組的值,鍵值是該值在原數(shù)組中出現(xiàn)的次數(shù)。2011-10-10

