Create a field in the database and record the file name. Each time a file is generated, the automatically generated file name is saved to the database. For recommended articles, you only need to point to the page in the specified folder where the static files are stored. Use PHP to operate the article list and save it as a string. replace this string when generating the page. For example, add the mark {articletable} to the table where the article list is placed on the page, and process the file in PHP:
PHP operation article list implementation code:
- <? Php
- $ Title = "http://siyizhu.com test template ";
- $ File = "TwoMax Inter test templet,
<Br> 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 );
- // Starts generating the list
- $ List = '';
- $ SQL = "select id, title, filename from article ";
- $ Query = mysql_query ($ SQL );
- While ($ result = mysql_fetch_array ($ query )){
- $ List. = '<a href ='. $ root. $ result ['filename'].'
Target = _ blank>'. $ Result ['title'].'</A> <br>';
- }
- $ Content. = str_replace ("{articletable }"
, $ List, $ content );
- // The generation list ends.
- // Echo $ content;
- $ Filename = "test/test.html ";
- $ Handle = fopen ($ filename, "w ");
// Open the file pointer and create a file
- /*
- Check whether the file is created and writable.
- */
- If (! Is_writable ($ filename )){
- Die ("file:". $ filename. "cannot be written,
Check its properties and try again! ");
- }
- If (! Fwrite ($ handle, $ content )){
// Write information to a file
- Die ("generate File". $ filename. "failed! ");
- }
- Fclose ($ handle); // close the pointer
- Die ("creating File". $ filename. "successful! ");
- ?>
The above code example shows how to use the PHP Operation Document list.