Help from a newbie: About the loop that generates static lists in PHP
°无恙。
°无恙。 2019-05-22 18:00:06
0
1
1055

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); 	
}


°无恙。
°无恙。

reply all(1)
殘留の回憶

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template