Let me ask you guys, PHP generates a static list. After the loop, the database value is normal, but the generated html data keeps repeating the data of the first loop.
for ($i=0; $i < $allpages; $i++){ if ($i==0) { $indexpath = "index_0.html"; } else { $indexpath = "index_".$i.".html"; } $star = $i* $onepage; $list =''; $sql= "select path,title from article limit $star,$onepage"; $result = mysql_query ($sql); while($row=mysql_fetch_assoc($result)) { $list.= '<a href="2019/'.$row['path'].'" target="_blank"><li>'.$row['title'].'</li></a><br>'; } $content = str_replace("{articletable}",$list,$content); if (is_file ($indexpath)) { @unlink ($indexpath); } $handle = fopen ($indexpath,"w"); fwrite ($handle,$content); fclose ($handle); }
You have been traversing the database in the for loop, and of course the data that comes out is repeated. Just put the while loop of the database outside and i inside it