Create a field in the database and record the file name. Every time a file is generated, the automatically generated file name is stored in the database. For recommended articles, just point to Just store the page in the specified folder where the static files are stored. Use PHP to operate the article list, save it as a string, and 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 in the PHP processing file:
PHP operation article list implementation code:
- < ?php
- $title = "http://siyizhu.com测试模板";
- $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);
- // 生成列表开始
-
$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);
- //生成列表结束
- // echo $content;
-
$filename = "test/test.html";
-
$handle = fopen ($filename,"w");
//打开文件指针,创建文件
- /*
- 检查文件是否被创建且可写
- */
- if (!is_writable ($filename)){
- die ("文件:".$filename."不可写,
Please check its properties and try again! "); - }
- if (!fwrite ($handle,$content)){
//Write information File - die ("Generate file".$filename."Failed!");
- }
- fclose ($handle); //Close pointer
- die ("Create file".$filename."Success!");
-
?>
The above code example is related to the use of PHP operation article list Method.
http://www.bkjia.com/PHPjc/445955.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445955.htmlTechArticleCreate a field in the database and record the file name. Each time a file is generated, the automatically generated file name is stored in the database. , for recommended articles, just point to the specified file where the static files are stored...