Blogger Information
Blog 12
fans 1
comment 1
visits 12109
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP用for循环做表格自动生成以及九九乘法表
Lucifer的博客
Original
2226 people have browsed it
<?php
/**
 * User: xujun
 * Date: 2017/12/26
 * Time: 23:40
 */
header('Content-Type: text/html; charset=utf-8');
echo "<h2 style='text-align: center'>自动生成表格</h2>";
echo <<<table
<form style="text-align: center;">
行:<input type="text" name="row">
列:<input type="text" name="col">
<button>提交</button>
</form>
table;

$row = isset($_GET['row'])?$_GET['row']:null;
$col =isset ($_GET['col'])?$_GET['col']:null;
$tab_str = '<table border="1" width="80%" align="center" cellspacing="0">';
for($i=0;$i<$row;$i++){
    $tab_str.="<tr>";
for($j=0;$j<$col;$j++){
    $k=$i *$col +$j;
    $tab_str.='<td align="center" >'.$k.'</td>';
}
    $tab_str.="</tr>";
}
$tab_str.='</table>';
echo $tab_str;

echo "<hr>";
echo "<h2 style='text-align: center'>九九乘法表</h2>";
echo '<table border="0" width="80%" align="center" >';
for($j=1; $j<=9; $j++) {
    echo '<tr>';
for($i=1; $i<=$j; $i++) {

echo "<td align='center' style=' border: solid #000 1px;'>".$i."x".$j."=".$i*$j."</td>";
}
    echo '</tr>';
}
echo '</table>';


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post