Output a table
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>23ptable</title>
<body>
<?php
Echo ' <table border= ' 1 "width=" align= "center" > ";
Echo ' <caption> uses a while loop output table </caption> ';
$i = 0;
while ($i <100) {
if ($i%10==0) {
echo "<tr>";} #此处, $i%10=0, exactly conditional statement set, output <tr>
echo "<td>". $i. " </td> ";
$i + +; #此处, $i is still 0.
if ($i%10==0) {
echo "</tr>";} /* here, $i is still 0, $i%10=0 set up, but the program out "}" is 1, if the $i + + is placed behind the IF,<tr></ The tr> is just a swap line, and the back loop will be in line * /
}
echo "</table>";
?>
</body>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can also achieve interlaced color change
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>23ptable</title>
<body>
<?php
Echo ' <table border= ' 1 "width=" align= "center" > ";
Echo ' <caption> uses a while loop output table </caption> ';
$i = 0;
while ($i <100) {
if ($i%10==0) {
if ($i%20==0) {$bg = "#fff999";} else{$BG = "#333fff";} effects such as
echo "<tr bgcolor= $bg >";}
echo "<td>". $i. " </td> ";
$i + +;
if ($i%10==0) {
echo "</tr>";}
}
echo "</table>";
?>
</body>
php-output a table