以下是引用片段: <?php $fp = fopen ("temp.html","r"); $content = fread ($fp,filesize ("temp.html")); $onepage = ’20’; $sql = "select id from article where channel=’$channelid’"; $query = mysql_query ($sql); $num = mysql_num_rows ($query); $allpages = ceil ($num / $onepage); for ($i = 0;$i<$allpages; $i++){ if ($i == 0){ $indexpath = "index.html"; } else { $indexpath = "index_".$i."html"; } $start = $i * $onepage; $list = ’’; $sql_for_page = "select name,filename,title from article where channel=’$channelid’ limit $start,$onepage"; $query_for_page = mysql_query ($sql_for_page); while ($result = $query_for_page){ $list .= ’<a href=’.$root.$result[’filename’].’ target=_blank>’.$title.’</a><br>’; } $content = str_replace ("{articletable}",$list,$content); if (is_file ($indexpath)){ @unlink ($indexpath); //若文件已存在,则删除 |