php将数据库中所有内容生成静态html文档的代码

前端之家收集整理的这篇文章主要介绍了php将数据库中所有内容生成静态html文档的代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="16923" class="copybut" id="copybut16923" onclick="doCopy('code16923')"> 代码如下:

<div class="codebody" id="code16923"> @H_502_2@<?PHP @H_5022@/* @H5022@author:www.5dkx.com @H502_2@done:生成html文档 @H_5022@date:2009-10-27 @H5022@*/ @H502_2@require_once("conn.PHP"); @H_502_2@if($GET['all']) @H5022@{ @H502_2@/获取数据库记录,以便于生成html文件有个文件/ @H_502_2@$sqlquery = "select from $tbname"; @H_502_2@$result = MysqL_query($sqlquery,$conn)or die("查询失败!"); @H_5022@$fp = fopen("./template/article.html",r); @H5022@$fpcontent = fread($fp,filesize("./template/article.html")); @H5022@fclose($fp); @H502_2@/写入文件/ @H_502_2@while($row = MysqL_fetcharray($result)) @H5022@{ @H502_2@$fpcontent = strreplace("{thetitle}",$row['title'],$fpcontent); @H502_2@$fpcontent = strreplace("{chatitle}",$fpcontent); @H502_2@$fpcontent = strreplace("{bookcontent}",$row['content'],$fpcontent); @H502_2@$fp = fopen("./html/".$row['id'].".html",w)or die("打开写入文件失败!"); @H_502_2@fwrite($fp,$fpcontent)or die("写入文件失败!"); @H_5022@} @H5022@echo "<script language=\"javascript\">alert('全部更新');"; @H5022@} @H502_2@if($GET['part']) @H5022@{ @H502_2@/获取最后一条记录的ID,以便于生成html文件有个文件/ @H_502_2@$sqlquery = "select from $tbname order by id desc limit 1"; @H_502_2@$result = MysqL_query($sqlquery,$conn)or die("查询失败!"); @H_502_2@$row = MysqL_fetcharray($result); @H5022@$fp = fopen("./template/article.html",filesize("./template/article.html")); @H5022@fclose($fp); @H502_2@$fpcontent = str_replace("{thetitle}",$fpcontent)or die("写入文件失败!"); @H_5022@echo "<script language=\"javascript\">alert('部分更新成功!');"; @H5022@} @H5022@?> @H5022@ @H5022@ @H502_2@<a href="/tag/shengcheng/" target="_blank" class="keywords">生成</a>html文档 @H_5022@<script language="javascript"> @H5022@function btnsubmit(form) @H5022@{ @H5022@theform.submit(); @H5022@} @H5022@ @H5022@ @H5022@ @H5022@<? @H5022@echo "<a href=?all=111>全部更新
<a href=?part=111>部分更新"; @H
5022@?> @H5022@ @H5022@ @H502_2@

猜你在找的PHP相关文章