Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
How to break a column to fix a php table

I had a little problem, i cannot break the table because I'm looking for a 16 columns in these table to create a unicode table... The aim is to find where i must break the line of the column as like as there:

<?php 

$columnas = 16;
$filas = 16;
$word= 0;
$contador = 0;

print "<table border=\"1\">\n";
print "<caption>ASCII</caption>\n";
print "<tbody>\n";
print "<tr>\n";

for ($j = 1; $j <= $columnas; $j++){
    if ($j%2 == 1){
        print "<th>Codigo</th>\n";
    }elseif ($j%2 == 0){
         print "<th>Valor</th>\n";
    }
}
print "</tr>";

for ($i = 1; $i <= $filas; $i++){

    for($i = 1; $i <= 50000; $i++,$contador){
        $unicodeChar = "&#{$i}";
        $contador--;
        print "<td>" .$i. "</td>\n";
        print "<td>".$unicodeChar."</td> \n";
    }   
    print "</tr>\n";
}   

print "</tbody>\n";
print "</table>\n";
 
?>

enter image description here

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

You used the modulus in the first loop, so use it again in the second

print "</tr>";

print "<tr>";
for($i = 1; $i <= 50000; $i++){
    $unicodeChar = "&#{$i}";
    $contador--;
    print "<td>$i</td><td>$unicodeChar</td>\n";

    if ( $i % $columnas/2 ) == 0 ) {
        print "</tr><tr>\n";
    }
}   
print "</tr>\n";
over 4 years ago · Santiago Trujillo Denunciar

0

Thank you very much for this help, i have been fixed!!

here is the code that i fixed, with your idea :)

´´´´

<?php 

$columnas = 16;
$filas = 16;
$word= 0;
$contador = 0;

print "<table border=\"1\">\n";
print "<caption>ASCII</caption>\n";
print "<tbody>\n";
print "<tr>\n";

for ($j = 1; $j <= $columnas; $j++){
    if ($j%2 == 1){
        print "<th>Codigo</th>\n";
    }elseif ($j%2 == 0){
         print "<th>Valor</th>\n";
    }
}
    print "</tr>";

    for ($i = 1; $i <= $filas; $i++){
        print "<tr>";       
        
        for($i = 1; $i <= 50000; $i++,$contador){
            $unicodeChar = "&#{$i}";
            $contador--;
                   print "<td>" .$i. "</td>\n";
            print "<td>".$unicodeChar."</td> \n";

            if (($i % 8 ) == 0 ){
                print "</tr><tr>";
            }
        }   
        print "</tr>\n";
    }
    

print "</tbody>\n";
print "</table>\n";
 
 ?>

´´´´

Table with these columns that fixed by this code php

over 4 years ago · Santiago Trujillo Denunciar

0

Like Riggsfolly said but maybe divide the columns number by 2 before the modulo, because there are 2 TDs / iteration:

if ( $i % ($columnas/2) ) == 0 ) {
    print "</tr><tr>\n";
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda