和剛才表格不同的是,對每行的列數有了更多的限制
即第一行一列,第二行兩列以此類推
所以
<code><span><<span>table</span><span>border</span>=<span>"1"</span><span>align</span>=<span>"center"</span><span>width</span>=<span>"800"</span>></span><span><<span>caption</span>></span><span><<span>h1</span>></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> < <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><<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> < <span>$i</span>+<span>1</span>; <span>$a</span>++) { <span>?></span></span><span><<span>td</span>></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></code>
以上就介紹了php日常3-21 設計一個九九乘法表,包含了面向的內容,希望對PHP教學有興趣的朋友有幫助。