和刚才表格不同的是,对每行的列数有了更多的限制
即第一行一列,第二行两列以此类推
所以
<code><span>table</span><span>border</span>=<span>"1"</span><span>align</span>=<span>"center"</span><span>width</span>=<span>"800"</span>><span>caption</span>><span>h1</span>>九九乘法表<span><span>h1</span>></span><span><span>caption</span>></span><span><span><?php </span><span>for</span> (<span>$i</span> = <span>1</span>; <span>$i</span> 10</span>; <span>$i</span>++) { <span>if</span>(<span>$i</span>%<span>2</span>==<span>0</span>){ <span>$bgc</span>=<span>"#ccc"</span>; } <span>else</span>{ <span>$bgc</span>=<span>"red"</span>; } <span>?></span></span><span>tr</span><span>bgcolor</span>=<span>"<?php echo "</span><span>$bgc"</span> ?></span>"> <span><span><?php </span><span>for</span> (<span>$a</span> = <span>1</span>; <span>$a</span> $i</span>+<span>1</span>; <span>$a</span>++) { <span>?></span></span><span>td</span>><span><span><?php </span><span>echo</span><span>"$a*$i="</span>; <span>echo</span><span>$i</span>*<span>$a</span><span>?></span></span><span><span>td</span>></span><span><span><?php </span> }<span>?></span></span><span><span>tr</span>></span><span><span><?php </span> }<span>?></span></span><span><span>table</span>></span></span></span></span></code>
以上就介绍了php日常3-21 设计一个九九乘法表,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。