Divide a table to optimize your page space

1

I have array and with it I make a table with data comparison, this table is too large (you have to scroll scroll of the mouse a lot) and the right side of the screen is blank.

Script:

reset($quebra);

while (key( $quebra) !== null) {

  // print("Numero do Array".key($quebra)."-- Resultado do Array ".current($quebra))."<br>\r\n";

  $row = explode (" " , key($quebra) . "=" . current($quebra));
  $posicao3 = strpos($row[0], '=');

  if (isset($ocupados[substr($row[0],$posicao3+1,4)]))
    $dadosweb .= "<tr ><td bgcolor=#FF0000>".substr($row[0],$posicao3+1,4)."</td><td >".$row[20]."</td>";
  else
    $dadosweb .= "<tr><td >".substr($row[0],$posicao3+1,4)."</td><td >".$row[20]."</td>";

  $dadosweb .= "<td ></td><td ></td></tr>";

  next($quebra);
}

Question

How can I split this table to better fit the page?

    
asked by anonymous 30.01.2014 / 13:01

1 answer

1

Use array_chunk with foreach / a>:

$tabelas = array_chunk($quebra, 20, true) // 20 = numero de linhas por tabela.
foreach ($tabelas as $tabela) {
    $dadosweb .= "<table>";
    foreach ($tabela as $key => $current) {
        $row = explode (" " , $key . "=" . $current);
        $posicao3 = strpos($row[0], '=');
        $dadosweb .= "<tr>";

        if (isset($ocupados[substr($row[0],$posicao3+1,4)])) {
            $dadosweb .= "<td bgcolor=#FF0000>".substr($row[0],$posicao3+1,4)."</td><td >".$row[20]."</td>";
        } else {
            $dadosweb .= "<td>".substr($row[0],$posicao3+1,4)."</td><td >".$row[20]."</td>";
        }

        $dadosweb .= "</tr>";
    }
    $dadosweb .= "</table>";
}
    
30.01.2014 / 13:17