-2
我正在处理下面的PHP脚本,我想通过使用php变量设置td高度和列,我无法弄清楚如何执行。任何提示和帮助,以帮助我解决它是不胜感激。谢谢。无法使用php variabile设置html表格高度和宽度
<?php
$n = 5;
$table_height = 100;
?>
<!DOCTYPE html>
<html>
<head>
<title>Your Table is Ready</title>
</head>
<body>
<table>
<?php for ($i = 0; $i < $n; $i++): ?>
<tr>
<?php for ($x = 0; $x < $n; $x++): ?>
<td height="{$table_height}"; width = "{$n}"><?php print($i * $x) ?></td>
<?php endfor ?>
</tr>
<?php endfor ?>
</table>
</body>
</html>
首先,你的变量不在PHP块内。另一方面,使用style属性会比'height'和'width'好,尽管它可能不如您期待的那样有效。 –