Copy CodeThe code is as follows:
/*
Author:www.5dkx.com
Done: Generating HTML documents
Date:2009-10-27
*/
Require_once ("conn.php");
if ($_get[' all ')
{
/* Get database records 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 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 (" Open write file failed! ");
Fwrite ($FP, $fpcontent) or Die ("Write file failed!");
}
echo "";
}
if ($_get[' part ')
{
/* Gets the ID of the last record so that the generated HTML file has a file name */
$sqlquery = "SELECT * from $tbname the 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 (" Open write file failed! ");
Fwrite ($FP, $fpcontent) or Die ("Write file failed!");
echo "";
}
?>
<title>Generating HTML documents</title>
echo "All updates
Partial Update ";
?>
http://www.bkjia.com/PHPjc/321556.html www.bkjia.com true http://www.bkjia.com/PHPjc/321556.html techarticle Copy the code as follows: PHP/* author:www.5dkx.com done: Generate HTML Document DATE:2009-10-27 */require_once ("conn.php"), if ($_get[' all ') { /* Get database records for easy generation ...