Split a table to optimize your page space

Asked

Viewed 1,008 times

1

I have a array and with it I make a table with data comparison, this table gets very big (it has to roll a lot the scroll mouse) and on 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 divide this table to better occupy the page ?

  • What do you mean "break the table"?

  • Shows the structure of your array, and if possible post a link as it is being done.

  • 1

    I took advantage of the edition of @lost and improved a little the information in the question. However, to better understand what is asked, you should elaborate the problem, put the cycle that is preparing HTML, but you want that cycle to process only half of the records found? Is that it? And the other half goes somewhere else? Note: A screenshot of the result you are getting and a description of what you would like to stay can go a long way in understanding your goal.

  • Maybe you can add: <p> next to the <tr>, and thus create another table with the <td>, I don’t know if that’s what you want to do.

  • Please follow the link, https://lh3.googleusercontent.com/-zvM49q_2L-E/UupD-Boymq/AAAAAAAAAAcAAAAAAA/POLyRXRhbYY/w894-h503-no/Captura+tela+de+2014-01-30+10%253A21%253A20.png but the data cannot repeat.

  • @Isac Borgert vc wants to centralize the table and 'paginate' the query?

  • Break it by placing limitation of <tr> you can do this either by pulling everything to the left or another table to the side.

  • I want the two columns containing data to be divided into a 6 columns, to better occupy the space of the page and not need to scroll too much scrool, and the data may not appear repeated on the screen.

  • @user3253024 how do I do this? I can’t repeat the data on the screen

Show 4 more comments

1 answer

1


Use the array_chunk with foreach:

$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>";
}
  • Looks like - that’s right, I’ll try, thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.