/*
author:www.5dkx.com
done: Generate html document
date:2009-10-27
*/
require_once("conn.php");
if($_GET['all'])
{
/*Get the database record so that the generated html file has a file name*/
$sqlquery = "select * from $tbname";
$result = mysql_query($sqlquery,$conn)or die ("Query failed!");
$fp = fopen("./template/article.html",r);
$fpcontent = fread($fp,filesize("./template/article.html" "));
fclose($fp);
/*Write to file*/
while($row = mysql_fetch_array($result))
{
$fpcontent = str_replace(" {thetitle}",$row['title'],$fpcontent);
$fpcontent = str_replace("{chatitle}",$row['title'],$fpcontent);
$fpcontent = str_replace ("{bookcontent}",$row['content'],$fpcontent);
$fp = fopen("./html/".$row['id'].".html",w)or die("Failed to open the file for writing!");
fwrite($fp,$fpcontent)or die("Failed to open the file for writing!");
}
echo "";
}
if($_GET['part'])
{
/*Get the last record ID, so that the html file has a file name */
$sqlquery = "select * from $tbname order by id desc limit 1";
$result = mysql_query($sqlquery,$conn)or die( "Query failed!");
$row = mysql_fetch_array($result);
$fp = fopen("./template/article.html",r);
$fpcontent = fread($fp ,filesize("./template/article.html"));
fclose($fp);
$fpcontent = str_replace("{thetitle}",$row['title'],$fpcontent);
$fpcontent = str_replace("{chatitle}",$row['title'],$fpcontent);
$fpcontent = str_replace("{bookcontent}",$row['content'],$fpcontent );
$fp = fopen("./html/".$row['id'].".html",w)or die("Failed to open file for writing!");
fwrite( $fp,$fpcontent)or die("Failed to write file!");
echo "";
}
?>
Generate html document echo "
All updatedPartial update" ;
?>