Wyświetlanie obrazków z folderu

Witam

Chciałbym zrobić skrypt, który będzie wyświetlał obrazki z folderu. Zrobiłem już tyle:

<?php

    if ($handle = opendir('galeria'))

        {

        while (false !== ($file = readdir($handle)))

            {

            if ($file != "." && $file != ".." && $file != "index.html")

                {

                echo "
";

                }

            }


        closedir($handle);

        }

?>[/code]

Nie wiem jak zrobić, aby obrazki wyświetlały się w rzędach np po 4 w jednym rzędzie.

Np.

<?php

    $t=1 ;

        if ($handle = opendir('galeria'))

            {

            while (false !== ($file = readdir($handle)))

                {

                if ($file != "." && $file != ".." && $file != "index.html")

                    {

                    echo "";

                    if ($t % 4 == 0) echo '
';

                    $t++;

                    }

                }

            closedir($handle);

            }

    ?>

[/code]