When I was building a website recently, I needed to generate static pages, but some content in the generated static pages needed to be obtained dynamically. Why couldn't I generate it every day? .
Finally, I checked online and added a summary, haha. . . . It finally happened. . Send it out for everyone to study together. . Oh. . .
Application 1: Article counting, obtaining dynamic content
Counting page: count.php
Copy code The code is as follows:
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?>");
Just add it to the static page mk.html
Remember: the page path and counting file path will change after static generation. .
Application 2: Get some dynamic information on this page, such as related articles
Similarly, links in static pages are still in this form
Copy code The code is as follows:
read.php contains the following content:
Copy code The code is as follows:
$cid=$_GET['cid'];
?>
document.write("
");
document.write("");
document.write("< TD width=33% align=center bgcolor=#ffffff>Order number");
document.write("Grade subject | ");
document. write("Time | ");
document.write("
");
$succquery=$DB-> query("select * from ".$tablepre."test where cid='$cid'");
while($succ=$DB->fetch_array($succquery))
{
? >
document.write("");
document.write("=$succ['id']?> | ");
document.write("=$succ['city']?> | ");
document.write(" =date('Y-m-d H:i:s',$succ['addtime'])?> | ");
document.write("
}
?>
document.write("
");
document.write("
" );
There is another method:
static side:
Copy code The code is as follows:
<script> <br>function fill_in(html) <br>{ <br>document.getElementById('into').innerHTML = html; <br>} <br></script>
dynamic page:
< html>
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>
< ;/body>
http://www.bkjia.com/PHPjc/320379.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320379.htmlTechArticleWhen I was building a website recently, I needed to generate static pages, but some content in the generated static pages needed to be obtained dynamically Yes, why can't it be generated every day? . Finally I checked online...