Nur ein Gedanke, dabei ist die Kommentartanzahl bei dir ja statisch, die Variable wurde von dir nicht mehr verändert, du musst $kommentaranzahl schon verändern.
################
#BILDERTABELLE:#
################
echo '<table>';
echo '<tr> <td>';
for($i = 0; $i < $filearray.length; $i++)
{
echo '<table>
<tr>
<td>
<a href="'.$Bilderordner.'/'.$fielarray[$i].'.html" target="Startseite">
</a>
</td>
<td>Anzahl der Kommentare: '.$kommentaranzahl.'</td>
</tr>
</table>
</td>';
if($i != 0 && $i%3 == 0) { // Drei Bilder in einer Reihe vorhanden
echo ' </tr>
<tr>';
}
echo '<td>;
}
echo '
</td>
</tr>
</table>';