Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Hola, soy nuevo en php y no puedo encontrar una manera de hacer un color de tabla alternativo en mi código. Siempre muestra la salida incorrecta que se requiere para que yo siga

Hice la regla nth child en css pero los colores no son alternativos. Los colores son todos iguales en cada fila y columna. Mi código es una tabla de multiplicar con un supuesto color alternativo. Tengo dificultades para saber qué debo hacer para modificar o agregar mi código php para crear el resultado deseado (colores alternativos en filas y columnas en la tabla de multiplicar).

A continuación se muestra mi código php:

 <?php for($row=0; $row<=10; $row++){ echo "<tr>"; for($column=0; $column<=10; $column++){ if($row==0 && $column==0){ echo "<td></td>"; } else{ echo "<td>". $row * $column. "</td>"; } } } echo "</tr>"; ?>

Código CSS:

 table, th, td { border: 1px solid black; } td { padding: 15px; } .bold{ font-weight: bold; font-size: 1.3em; } table tr:nth-child(odd) { background-color: yellow; } table tr:nth-child(even) { background-color: red; }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

olvida usar la etiqueta <table> y su dirección CSS desde la tabla.

 <?php echo "<table>"; for($row=0; $row<=10; $row++){ echo "<tr>"; for($column=0; $column<=10; $column++){ if($row==0 && $column==0){ echo "<td></td>"; } else{ echo "<td>". $row * $column. "</td>"; } } echo "</tr>"; } echo "</table>"; ?>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!