search
Homephp教程php手册php 静态页面中显示动态内容

php 静态页面中显示动态内容

Jun 13, 2016 pm 12:22 PM
phpbutcontentdynamichourshowgenerateofsiteneedstaticpage

最近在做一个站点时,需要生成静态页面,但是生成的静态页面中有些内容是需要动态获取的,怎不能每天生成一下吧。。
最后上网查了一下,再加上个要总结,呵。。。。终于实现了。。发出来,大家一起研究。。呵。。。
应用一:文章计数,获取动态内容
计数页:count.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中加入即可

切记:页面路径,生成静态后计数文件路径会变。。
应用二:获取此页面中一些动态信息,例如相关文章之类
同样,静态页面中的链接还是此种形式

复制代码 代码如下:




read.php里内容如下:

复制代码 代码如下:


$cid=$_GET['cid'];
?>
document.write("

");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
$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("");
}
?>
document.write("
订单号年级科目时间
=$succ['id']?>=$succ['city']?>=date('Y-m-d H:i:s',$succ['addtime'])?>
");
document.write("
");

还有另外一种方法:
static side:

复制代码 代码如下:



<script> <BR>function fill_in(html) <BR>{ <BR>document.getElementById('into').innerHTML = html; <BR>} <BR></script>



dynamic page:

fill in any thing that is dynamic without document.write()

<script> <BR>var html = document.getElementById('content').innerHTML; <BR>parent.fill_in(html); <BR>document.getElementById('content').innerHTML = ""; <BR></script>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft