for schleife problem

VillaiN

Grünschnabel
ich möchte mehrere bilder in eine tabelle automatisch einbinden lassen sodass immer 3 in einer Reihe sind also sagen wir mal ich hab 12 bilder also sollte es folgendermassen aussehen

Bild 1 Bild 2 Bild 3
Bild 4 Bild 5 Bild 6
usw...


momentan bin ich soweit das ich die bilder alle untereinander habe aber ich möcht ja 3 nebeneinander hier is mein code plz help

PHP:
echo "
<table border='0' cellspacing='0' cellpadding='5'><tr>";

        for ($i=1;$i<=12;$i++) {
       	echo " <td><img src='../images/$row[3]/k00$i.jpg'></td> ";
        }	
        echo "	</tr>
		</table>";
 
Es geht auch schöner: Mit dem modulo-Operator:
PHP:
$umbruchat = 3;
for ($i=0; $i<$anzbilder; $i++) {
    ...

    if (($i % $umbruchat) == 0) echo "<br>\n";
}
 
Zurück