Generate html static page code for all the content in the database
- Require_once ("conn. php ");
- If ($ _ GET ['all'])
- {
- /* Obtain database records to generate html files with 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 ("Opening and writing files failed! ");
- Fwrite ($ fp, $ fpcontent) or die ("failed to write file! ");
- }
- Echo"
|