function generatehtm($newsid){
global $ObjectMyClass; //在session_start();下面把它实例化
$sql= "select * from f_news where newsid=$newsid";
$result=$ObjectMyClass->query($sql);
$row=mysql_fetch_assoc($result);
$fp = fopen ("static.html","r"); //只读方式打开 static.html模板,将文件指针指向文件头
$tempLate= fread ($fp,filesize ("static.html")); //读取整个文件内容
$tempLate = str_replace("{title}",$row["title"],$tempLate);
$tempLate = str_replace("{keywords}",$row["keywords"],$tempLate);
$tempLate = str_replace("{Description}",$row["Description"],$tempLate);
$tempLate = str_replace("{time}",formatdate(1,$row["updatetime"]),$tempLate);
$tempLate = str_replace("{source}",$row["source"],$tempLate);
$tempLate = str_replace("{newsid}",$row["newsid"],$tempLate);
$tmpBody = $row["text"];
$tmpArray = PageNews($tmpBody);//保存到一个数组再生成分页地址,然后再由根据explode分的数组的内容生成htm 页面
$total = count($tmpArray);
if( $total >1 ){
$tmpStr = '';
for( $i=0;$i'.$str.'';
$tempLate = str_replace('{page}',$str,$tempLate);
for( $j=0;$j<$total;$j++ ){
if( $j==0 ){
$fname =$newsid.'.htm';
}else{
$fname =$newsid.'_'.$j.'.htm';
}
$tempMu = str_replace('{htmlContent}',$tmpArray[$j],$tempLate);
makeHtml($tempMu,$fname,"");
}
$mupage =1;
}
}
//创建文件
function makeHtml($tempMu,$file,$fname){
$filePath = 'html/'.date('Ymd');
if (!file_exists($filePath)){
createFolder($filePath);
}
$fp = fopen($filePath.'/'.$file, "w");
fwrite($fp,$tempMu);
fclose($fp);
}
function createFolder($path){
if (!file_exists($path)){
createFolder(dirname($path));
mkdir($path, 0777);
}
}
第一页为 1〔2〕〔3〕〔4〕
第二页为 〔1〕2〔3〕〔4〕
第三页为 〔1〕〔2〕3〔4〕
第四页为 〔1〕〔2〕〔3〕4
大哥大姐,小弟在这里救助各位大侠了,请问要怎么写能实现呀
css和js不能控制到吧。 大侠可以说得清楚一些,嘿。。 可以举例说明一下吗?
这个问题被弄得头好大。
|