Create a field in the database, record the file name, each file is generated, the automatically generated file name is stored in the database, for the recommended article, just point to the page in the specified folder that holds the static file. Use PHP to manipulate the list of articles, save as a string, and replace this string when generating a page. For example, the table that places the list of articles in the page is added with the tag {articletable}, and in the PHP processing file:
PHP operation article List implementation code:
- < ? PHP
- $ title = "http://siyizhu.com test Template" ;
- $ file = "Twomax Inter test Templet,
Author:matrix@two_max ";
- $ FP = fopen ("temp.html", "R");
- $ content = fread ($FP, FileSize ("temp.html"));
- $ content = Str_replace ("{file}", $file, $content);
- $ content = Str_replace ("{title}", $title, $content);
- Build list Start
- $ List = '' ;
- $ SQL = "Select Id,title,filename from article" ;
- $ Query = mysql_query ($sql);
- While ($result = mysql_fetch_array ($query)) {
- $list . = ' . $root. $result [' filename ']. '
target=_blank>'. $result [' title ']. ' a><br> ';
- }
- $content . = Str_replace ("{articletable}"
, $list, $content);
- End of Build list
- Echo $content;
- $ filename = "Test/test.html" ;
- $ Handle = fopen ($filename, "w");
Open file pointer, create file
- /*
- Check if the file is created and writable
- */
- if (!is_writable ($filename)) {
- Die ("File:". $filename. " Not writable,
Please check its properties and try again! ");
- }
- if (!fwrite ($handle, $content)) {
Writing information to a file
- Die ("Generate file". $filename. " Failed! ");
- }
- Fclose ($handle); Close pointer
- Die ("Create file". $filename. " Success! ");
- ?>
The above code example is how to use the PHP action article list.
http://www.bkjia.com/PHPjc/445955.html www.bkjia.com true http://www.bkjia.com/PHPjc/445955.html techarticle Create a field in the database, record the file name, each file is generated, the automatically generated file name into the database, for the recommended article, simply point to the file that holds the static file ...