-
CREATE TABLE `bihtml` (
`id` int(11) NOT NULL auto_increment,
`szdtitle` varchar(16) NOT NULL,
`szdcontent` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
获取当前的ID,并导入模板:
ob_start();
$id=_POST['id']
if(!isset($id)&&is_integer($id))
{
@$db=new mysqli('localhost','root','admin','bihtml');
$result=$db->fetch_one_array("select * from szd_bi where id='$id'");
if(!empty($result))
{
$tmp->assign(array(
"Szdtitle",htmlspecialchars($result['titles']),
"Szdcontent",$result['titles']));
}
$tpl->display('default_1.tpl');
$this_my_f= ob_get_contents(); //此处关键
ob_end_clean();
$filename = "$id.html";
if(tohtmlfile_cjjer($filename,$this_my_f))
echo "生成成功 $filename";
else
echo "生成失败";
}
}//把生成文件的过程写出函数
function tohtmlfile_cjjer($file_cjjer_name,$file_cjjer_content)
{
if (is_file ($file_cjjer_name)){
@unlink ($file_cjjer_name);
}
$cjjer_handle = fopen ($file_cjjer_name,"w");
if (!is_writable ($file_cjjer_name)){
return false;
}
if (!fwrite ($cjjer_handle,$file_cjjer_content)){
return false;
}
fclose ($cjjer_handle); //关闭指针
return $file_cjjer_name;
}2012年3月14日网络转载
- 下一篇:中小型企业网站建设方案 上一篇:企业选取域名的原则和技巧