Table with certain rows and columns PHP

0

I'm doing a kind of "gallery" in PHP (which reads and shows the photos of the server) in which there is a main form where you choose the number of rows and the number of columns and if for example I put 2 columns and 3 rows (in total 6 cells) and in the server I have 100 images, that only show me those 6 and not all those that are on the server. What I have tried is to make a table with a cycle for in the columns and rows, but it does not work out, it shows me all the images. Sorry if I have not explained myself well, here is the code:

//Leer número archivos de la carpeta según lo indicado

//Bucle para seleccionar filas y columnas

for($i=0; $i<=$numFilas; $i++){
    echo "<tr>";
    for($w=0; $w<=$numColumnas; $w++){
        echo "<td>";
        while( /*$i<=$numImagenes+1 && */$file = readdir($filehandle)){
            if($file != "." && $file != ".."){
                $tamanyo = GetImageSize($ruta . $file);

                echo "<td><img style = 'padding: 3px; border: 2px solid #A9FF93' src='$ruta$file' $tamanyo[3]></td>";

                $patron = "/I_(.*)_IH_(.*)_HP_(.*)_PN_(.*)_N\./";
                $result = preg_match($patron, $file, $resultados);

                $nombreCompleto = $resultados[0];
                $vecesMostrar = $resultados[1];
                $horariosProhibidos = $resultados[2];
                $periodo = $resultados[3];
                $nombre = $resultados[4];

                //Llamo a la función que se encarga de agregar los registros
                agregarImpresiones($nombre,$ruta, $vecesMostrar, $horariosProhibidos, $periodo);
                impresionesTotales($nombre, $ruta, $periodo, $vecesMostrar);
                    mostrarXVeces($nombre);
            }//end if
            //$i++;
        }//end while
        echo "</td>";                           
    }//end for
    echo "</tr>";
}//end for'

Thank you very much for the help!

    
asked by Csc99 08.05.2018 в 11:29
source

0 answers