# 每行具有不同文本颜色的乘法

2023-05-26 17:20:22

function multiplication_table(\$rows, \$cols){

echo "<table width =\"500\" height=\"500\" border=\"50\">";

for (\$row = 1; \$row <= \$rows; \$row++){

echo'<tr>';

for (\$col = 1; \$col <= \$cols; \$col++)

echo '<td align = "center">' .\$col*\$row.'</td>';

echo '</tr>';

}

echo"</table>";

}

## 2 回答

TA贡献1700条经验 获得超7个赞

function multiplication_table(\$rows, \$cols){

echo "<table width =\"500\" height=\"500\" border=\"50\">";

for (\$row = 1; \$row <= \$rows; \$row++){

echo'<tr class="row'+\$row+'">';

for (\$col = 1; \$col <= \$cols; \$col++)

echo '<td align = "center">' .\$col*\$row.'</td>';

echo '</tr>';

}

echo"</table>";

}

.row1 , .row1 td

{

background:red;

}

TA贡献1652条经验 获得超9个赞

function multiplication_table(\$rows, \$cols){

echo "<table width =\"500\" height=\"500\" border=\"50\">";

for (\$row = 1; \$row <= \$rows; \$row++){

// Generate Random Color

\$color = "#".substr(md5(rand()), 0, 6);

// Apply color to row

echo'<tr style="background-color:'.\$color.'">';

for (\$col = 1; \$col <= \$cols; \$col++)

echo '<td align = "center">' .\$col*\$row.'</td>';

echo '</tr>';

}

echo"</table>";

}

• 2 回答
• 0 关注
• 15 浏览

0/150